google_cloudbilling1/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 /// View and manage your Google Cloud Platform billing accounts
17 CloudBilling,
18
19 /// View your Google Cloud Platform billing accounts
20 CloudBillingReadonly,
21
22 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
23 CloudPlatform,
24}
25
26impl AsRef<str> for Scope {
27 fn as_ref(&self) -> &str {
28 match *self {
29 Scope::CloudBilling => "https://www.googleapis.com/auth/cloud-billing",
30 Scope::CloudBillingReadonly => "https://www.googleapis.com/auth/cloud-billing.readonly",
31 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
32 }
33 }
34}
35
36#[allow(clippy::derivable_impls)]
37impl Default for Scope {
38 fn default() -> Scope {
39 Scope::CloudBillingReadonly
40 }
41}
42
43// ########
44// HUB ###
45// ######
46
47/// Central instance to access all Cloudbilling related resource activities
48///
49/// # Examples
50///
51/// Instantiate a new hub
52///
53/// ```test_harness,no_run
54/// extern crate hyper;
55/// extern crate hyper_rustls;
56/// extern crate google_cloudbilling1 as cloudbilling1;
57/// use cloudbilling1::{Result, Error};
58/// # async fn dox() {
59/// use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60///
61/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
62/// // `client_secret`, among other things.
63/// let secret: yup_oauth2::ApplicationSecret = Default::default();
64/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
65/// // unless you replace `None` with the desired Flow.
66/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
67/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
68/// // retrieve them from storage.
69/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
70/// .with_native_roots()
71/// .unwrap()
72/// .https_only()
73/// .enable_http2()
74/// .build();
75///
76/// let executor = hyper_util::rt::TokioExecutor::new();
77/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
78/// secret,
79/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
80/// yup_oauth2::client::CustomHyperClientBuilder::from(
81/// hyper_util::client::legacy::Client::builder(executor).build(connector),
82/// ),
83/// ).build().await.unwrap();
84///
85/// let client = hyper_util::client::legacy::Client::builder(
86/// hyper_util::rt::TokioExecutor::new()
87/// )
88/// .build(
89/// hyper_rustls::HttpsConnectorBuilder::new()
90/// .with_native_roots()
91/// .unwrap()
92/// .https_or_http()
93/// .enable_http2()
94/// .build()
95/// );
96/// let mut hub = Cloudbilling::new(client, auth);
97/// // You can configure optional parameters by calling the respective setters at will, and
98/// // execute the final call using `doit()`.
99/// // Values shown here are possibly random and not representative !
100/// let result = hub.billing_accounts().sub_accounts_list("parent")
101/// .page_token("takimata")
102/// .page_size(-52)
103/// .filter("duo")
104/// .doit().await;
105///
106/// match result {
107/// Err(e) => match e {
108/// // The Error enum provides details about what exactly happened.
109/// // You can also just use its `Debug`, `Display` or `Error` traits
110/// Error::HttpError(_)
111/// |Error::Io(_)
112/// |Error::MissingAPIKey
113/// |Error::MissingToken(_)
114/// |Error::Cancelled
115/// |Error::UploadSizeLimitExceeded(_, _)
116/// |Error::Failure(_)
117/// |Error::BadRequest(_)
118/// |Error::FieldClash(_)
119/// |Error::JsonDecodeError(_, _) => println!("{}", e),
120/// },
121/// Ok(res) => println!("Success: {:?}", res),
122/// }
123/// # }
124/// ```
125#[derive(Clone)]
126pub struct Cloudbilling<C> {
127 pub client: common::Client<C>,
128 pub auth: Box<dyn common::GetToken>,
129 _user_agent: String,
130 _base_url: String,
131 _root_url: String,
132}
133
134impl<C> common::Hub for Cloudbilling<C> {}
135
136impl<'a, C> Cloudbilling<C> {
137 pub fn new<A: 'static + common::GetToken>(
138 client: common::Client<C>,
139 auth: A,
140 ) -> Cloudbilling<C> {
141 Cloudbilling {
142 client,
143 auth: Box::new(auth),
144 _user_agent: "google-api-rust-client/7.0.0".to_string(),
145 _base_url: "https://cloudbilling.googleapis.com/".to_string(),
146 _root_url: "https://cloudbilling.googleapis.com/".to_string(),
147 }
148 }
149
150 pub fn billing_accounts(&'a self) -> BillingAccountMethods<'a, C> {
151 BillingAccountMethods { hub: self }
152 }
153 pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
154 OrganizationMethods { hub: self }
155 }
156 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
157 ProjectMethods { hub: self }
158 }
159 pub fn services(&'a self) -> ServiceMethods<'a, C> {
160 ServiceMethods { hub: self }
161 }
162
163 /// Set the user-agent header field to use in all requests to the server.
164 /// It defaults to `google-api-rust-client/7.0.0`.
165 ///
166 /// Returns the previously set user-agent.
167 pub fn user_agent(&mut self, agent_name: String) -> String {
168 std::mem::replace(&mut self._user_agent, agent_name)
169 }
170
171 /// Set the base url to use in all requests to the server.
172 /// It defaults to `https://cloudbilling.googleapis.com/`.
173 ///
174 /// Returns the previously set base url.
175 pub fn base_url(&mut self, new_base_url: String) -> String {
176 std::mem::replace(&mut self._base_url, new_base_url)
177 }
178
179 /// Set the root url to use in all requests to the server.
180 /// It defaults to `https://cloudbilling.googleapis.com/`.
181 ///
182 /// Returns the previously set root url.
183 pub fn root_url(&mut self, new_root_url: String) -> String {
184 std::mem::replace(&mut self._root_url, new_root_url)
185 }
186}
187
188// ############
189// SCHEMAS ###
190// ##########
191/// Represents the aggregation level and interval for pricing of a single SKU.
192///
193/// This type is not used in any activity, and only used as *part* of another schema.
194///
195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
196#[serde_with::serde_as]
197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
198pub struct AggregationInfo {
199 /// The number of intervals to aggregate over. Example: If aggregation_level is "DAILY" and aggregation_count is 14, aggregation will be over 14 days.
200 #[serde(rename = "aggregationCount")]
201 pub aggregation_count: Option<i32>,
202 /// no description provided
203 #[serde(rename = "aggregationInterval")]
204 pub aggregation_interval: Option<String>,
205 /// no description provided
206 #[serde(rename = "aggregationLevel")]
207 pub aggregation_level: Option<String>,
208}
209
210impl common::Part for AggregationInfo {}
211
212/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
213///
214/// This type is not used in any activity, and only used as *part* of another schema.
215///
216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
217#[serde_with::serde_as]
218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
219pub struct AuditConfig {
220 /// The configuration for logging of each type of permission.
221 #[serde(rename = "auditLogConfigs")]
222 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
223 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
224 pub service: Option<String>,
225}
226
227impl common::Part for AuditConfig {}
228
229/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
230///
231/// This type is not used in any activity, and only used as *part* of another schema.
232///
233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
234#[serde_with::serde_as]
235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
236pub struct AuditLogConfig {
237 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
238 #[serde(rename = "exemptedMembers")]
239 pub exempted_members: Option<Vec<String>>,
240 /// The log type that this config enables.
241 #[serde(rename = "logType")]
242 pub log_type: Option<String>,
243}
244
245impl common::Part for AuditLogConfig {}
246
247/// A billing account in the [Google Cloud Console](https://console.cloud.google.com/). You can assign a billing account to one or more projects.
248///
249/// # Activities
250///
251/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
252/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
253///
254/// * [projects list billing accounts](BillingAccountProjectListCall) (none)
255/// * [sub accounts create billing accounts](BillingAccountSubAccountCreateCall) (request|response)
256/// * [sub accounts list billing accounts](BillingAccountSubAccountListCall) (none)
257/// * [create billing accounts](BillingAccountCreateCall) (request|response)
258/// * [get billing accounts](BillingAccountGetCall) (response)
259/// * [get iam policy billing accounts](BillingAccountGetIamPolicyCall) (none)
260/// * [list billing accounts](BillingAccountListCall) (none)
261/// * [move billing accounts](BillingAccountMoveCall) (response)
262/// * [patch billing accounts](BillingAccountPatchCall) (request|response)
263/// * [set iam policy billing accounts](BillingAccountSetIamPolicyCall) (none)
264/// * [test iam permissions billing accounts](BillingAccountTestIamPermissionCall) (none)
265/// * [billing accounts create organizations](OrganizationBillingAccountCreateCall) (request|response)
266/// * [billing accounts move organizations](OrganizationBillingAccountMoveCall) (response)
267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
268#[serde_with::serde_as]
269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
270pub struct BillingAccount {
271 /// Optional. The currency in which the billing account is billed and charged, represented as an ISO 4217 code such as `USD`. Billing account currency is determined at the time of billing account creation and cannot be updated subsequently, so this field should not be set on update requests. In addition, a subaccount always matches the currency of its parent billing account, so this field should not be set on subaccount creation requests. Clients can read this field to determine the currency of an existing billing account.
272 #[serde(rename = "currencyCode")]
273 pub currency_code: Option<String>,
274 /// The display name given to the billing account, such as `My Billing Account`. This name is displayed in the Google Cloud Console.
275 #[serde(rename = "displayName")]
276 pub display_name: Option<String>,
277 /// If this account is a [subaccount](https://cloud.google.com/billing/docs/concepts), then this will be the resource name of the parent billing account that it is being resold through. Otherwise this will be empty.
278 #[serde(rename = "masterBillingAccount")]
279 pub master_billing_account: Option<String>,
280 /// Output only. The resource name of the billing account. The resource name has the form `billingAccounts/{billing_account_id}`. For example, `billingAccounts/012345-567890-ABCDEF` would be the resource name for billing account `012345-567890-ABCDEF`.
281 pub name: Option<String>,
282 /// Output only. True if the billing account is open, and will therefore be charged for any usage on associated projects. False if the billing account is closed, and therefore projects associated with it are unable to use paid services.
283 pub open: Option<bool>,
284 /// Output only. The billing account's parent resource identifier. Use the `MoveBillingAccount` method to update the account's parent resource if it is a organization. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
285 pub parent: Option<String>,
286}
287
288impl common::RequestValue for BillingAccount {}
289impl common::Resource for BillingAccount {}
290impl common::ResponseResult for BillingAccount {}
291
292/// Associates `members`, or principals, with a `role`.
293///
294/// This type is not used in any activity, and only used as *part* of another schema.
295///
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct Binding {
300 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
301 pub condition: Option<Expr>,
302 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
303 pub members: Option<Vec<String>>,
304 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
305 pub role: Option<String>,
306}
307
308impl common::Part for Binding {}
309
310/// Represents the category hierarchy of a SKU.
311///
312/// This type is not used in any activity, and only used as *part* of another schema.
313///
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct Category {
318 /// The type of product the SKU refers to. Example: "Compute", "Storage", "Network", "ApplicationServices" etc.
319 #[serde(rename = "resourceFamily")]
320 pub resource_family: Option<String>,
321 /// A group classification for related SKUs. Example: "RAM", "GPU", "Prediction", "Ops", "GoogleEgress" etc.
322 #[serde(rename = "resourceGroup")]
323 pub resource_group: Option<String>,
324 /// The display name of the service this SKU belongs to.
325 #[serde(rename = "serviceDisplayName")]
326 pub service_display_name: Option<String>,
327 /// Represents how the SKU is consumed. Example: "OnDemand", "Preemptible", "Commit1Mo", "Commit1Yr" etc.
328 #[serde(rename = "usageType")]
329 pub usage_type: Option<String>,
330}
331
332impl common::Part for Category {}
333
334/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
335///
336/// This type is not used in any activity, and only used as *part* of another schema.
337///
338#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
339#[serde_with::serde_as]
340#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
341pub struct Expr {
342 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
343 pub description: Option<String>,
344 /// Textual representation of an expression in Common Expression Language syntax.
345 pub expression: Option<String>,
346 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
347 pub location: Option<String>,
348 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
349 pub title: Option<String>,
350}
351
352impl common::Part for Expr {}
353
354/// Encapsulates the geographic taxonomy data for a sku.
355///
356/// This type is not used in any activity, and only used as *part* of another schema.
357///
358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
359#[serde_with::serde_as]
360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
361pub struct GeoTaxonomy {
362 /// The list of regions associated with a sku. Empty for Global skus, which are associated with all Google Cloud regions.
363 pub regions: Option<Vec<String>>,
364 /// The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL.
365 #[serde(rename = "type")]
366 pub type_: Option<String>,
367}
368
369impl common::Part for GeoTaxonomy {}
370
371/// Response message for `ListBillingAccounts`.
372///
373/// # Activities
374///
375/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
376/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
377///
378/// * [sub accounts list billing accounts](BillingAccountSubAccountListCall) (response)
379/// * [list billing accounts](BillingAccountListCall) (response)
380/// * [billing accounts list organizations](OrganizationBillingAccountListCall) (response)
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct ListBillingAccountsResponse {
385 /// A list of billing accounts.
386 #[serde(rename = "billingAccounts")]
387 pub billing_accounts: Option<Vec<BillingAccount>>,
388 /// A token to retrieve the next page of results. To retrieve the next page, call `ListBillingAccounts` again with the `page_token` field set to this value. This field is empty if there are no more results to retrieve.
389 #[serde(rename = "nextPageToken")]
390 pub next_page_token: Option<String>,
391}
392
393impl common::ResponseResult for ListBillingAccountsResponse {}
394
395/// Request message for `ListProjectBillingInfoResponse`.
396///
397/// # Activities
398///
399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
401///
402/// * [projects list billing accounts](BillingAccountProjectListCall) (response)
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct ListProjectBillingInfoResponse {
407 /// A token to retrieve the next page of results. To retrieve the next page, call `ListProjectBillingInfo` again with the `page_token` field set to this value. This field is empty if there are no more results to retrieve.
408 #[serde(rename = "nextPageToken")]
409 pub next_page_token: Option<String>,
410 /// A list of `ProjectBillingInfo` resources representing the projects associated with the billing account.
411 #[serde(rename = "projectBillingInfo")]
412 pub project_billing_info: Option<Vec<ProjectBillingInfo>>,
413}
414
415impl common::ResponseResult for ListProjectBillingInfoResponse {}
416
417/// Response message for `ListServices`.
418///
419/// # Activities
420///
421/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
422/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
423///
424/// * [list services](ServiceListCall) (response)
425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
426#[serde_with::serde_as]
427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
428pub struct ListServicesResponse {
429 /// A token to retrieve the next page of results. To retrieve the next page, call `ListServices` again with the `page_token` field set to this value. This field is empty if there are no more results to retrieve.
430 #[serde(rename = "nextPageToken")]
431 pub next_page_token: Option<String>,
432 /// A list of services.
433 pub services: Option<Vec<Service>>,
434}
435
436impl common::ResponseResult for ListServicesResponse {}
437
438/// Response message for `ListSkus`.
439///
440/// # Activities
441///
442/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
443/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
444///
445/// * [skus list services](ServiceSkuListCall) (response)
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct ListSkusResponse {
450 /// A token to retrieve the next page of results. To retrieve the next page, call `ListSkus` again with the `page_token` field set to this value. This field is empty if there are no more results to retrieve.
451 #[serde(rename = "nextPageToken")]
452 pub next_page_token: Option<String>,
453 /// The list of public SKUs of the given service.
454 pub skus: Option<Vec<Sku>>,
455}
456
457impl common::ResponseResult for ListSkusResponse {}
458
459/// Represents an amount of money with its currency type.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct Money {
467 /// The three-letter currency code defined in ISO 4217.
468 #[serde(rename = "currencyCode")]
469 pub currency_code: Option<String>,
470 /// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
471 pub nanos: Option<i32>,
472 /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
473 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
474 pub units: Option<i64>,
475}
476
477impl common::Part for Money {}
478
479/// Request message for `MoveBillingAccount` RPC.
480///
481/// # Activities
482///
483/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
484/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
485///
486/// * [move billing accounts](BillingAccountMoveCall) (request)
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct MoveBillingAccountRequest {
491 /// Required. The resource name of the Organization to move the billing account under. Must be of the form `organizations/{organization_id}`.
492 #[serde(rename = "destinationParent")]
493 pub destination_parent: Option<String>,
494}
495
496impl common::RequestValue for MoveBillingAccountRequest {}
497
498/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
499///
500/// # Activities
501///
502/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
503/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
504///
505/// * [get iam policy billing accounts](BillingAccountGetIamPolicyCall) (response)
506/// * [set iam policy billing accounts](BillingAccountSetIamPolicyCall) (response)
507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
508#[serde_with::serde_as]
509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
510pub struct Policy {
511 /// Specifies cloud audit logging configuration for this policy.
512 #[serde(rename = "auditConfigs")]
513 pub audit_configs: Option<Vec<AuditConfig>>,
514 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
515 pub bindings: Option<Vec<Binding>>,
516 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
517 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
518 pub etag: Option<Vec<u8>>,
519 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
520 pub version: Option<i32>,
521}
522
523impl common::ResponseResult for Policy {}
524
525/// Expresses a mathematical pricing formula. For Example:- `usage_unit: GBy` `tiered_rates:` `[start_usage_amount: 20, unit_price: $10]` `[start_usage_amount: 100, unit_price: $5]` The above expresses a pricing formula where the first 20GB is free, the next 80GB is priced at $10 per GB followed by $5 per GB for additional usage.
526///
527/// This type is not used in any activity, and only used as *part* of another schema.
528///
529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
530#[serde_with::serde_as]
531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
532pub struct PricingExpression {
533 /// The base unit for the SKU which is the unit used in usage exports. Example: "By"
534 #[serde(rename = "baseUnit")]
535 pub base_unit: Option<String>,
536 /// Conversion factor for converting from price per usage_unit to price per base_unit, and start_usage_amount to start_usage_amount in base_unit. unit_price / base_unit_conversion_factor = price per base_unit. start_usage_amount * base_unit_conversion_factor = start_usage_amount in base_unit.
537 #[serde(rename = "baseUnitConversionFactor")]
538 pub base_unit_conversion_factor: Option<f64>,
539 /// The base unit in human readable form. Example: "byte".
540 #[serde(rename = "baseUnitDescription")]
541 pub base_unit_description: Option<String>,
542 /// The recommended quantity of units for displaying pricing info. When displaying pricing info it is recommended to display: (unit_price * display_quantity) per display_quantity usage_unit. This field does not affect the pricing formula and is for display purposes only. Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and the display_quantity is "1000" then the recommended way of displaying the pricing info is "0.10 USD per 1000 GB"
543 #[serde(rename = "displayQuantity")]
544 pub display_quantity: Option<f64>,
545 /// The list of tiered rates for this pricing. The total cost is computed by applying each of the tiered rates on usage. This repeated list is sorted by ascending order of start_usage_amount.
546 #[serde(rename = "tieredRates")]
547 pub tiered_rates: Option<Vec<TierRate>>,
548 /// The short hand for unit of usage this pricing is specified in. Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte".
549 #[serde(rename = "usageUnit")]
550 pub usage_unit: Option<String>,
551 /// The unit of usage in human readable form. Example: "gibi byte".
552 #[serde(rename = "usageUnitDescription")]
553 pub usage_unit_description: Option<String>,
554}
555
556impl common::Part for PricingExpression {}
557
558/// Represents the pricing information for a SKU at a single point of time.
559///
560/// This type is not used in any activity, and only used as *part* of another schema.
561///
562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
563#[serde_with::serde_as]
564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
565pub struct PricingInfo {
566 /// Aggregation Info. This can be left unspecified if the pricing expression doesn't require aggregation.
567 #[serde(rename = "aggregationInfo")]
568 pub aggregation_info: Option<AggregationInfo>,
569 /// Conversion rate used for currency conversion, from USD to the currency specified in the request. This includes any surcharge collected for billing in non USD currency. If a currency is not specified in the request this defaults to 1.0. Example: USD * currency_conversion_rate = JPY
570 #[serde(rename = "currencyConversionRate")]
571 pub currency_conversion_rate: Option<f64>,
572 /// The timestamp from which this pricing was effective within the requested time range. This is guaranteed to be greater than or equal to the start_time field in the request and less than the end_time field in the request. If a time range was not specified in the request this field will be equivalent to a time within the last 12 hours, indicating the latest pricing info.
573 #[serde(rename = "effectiveTime")]
574 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
575 /// Expresses the pricing formula. See `PricingExpression` for an example.
576 #[serde(rename = "pricingExpression")]
577 pub pricing_expression: Option<PricingExpression>,
578 /// An optional human readable summary of the pricing information, has a maximum length of 256 characters.
579 pub summary: Option<String>,
580}
581
582impl common::Part for PricingInfo {}
583
584/// Encapsulation of billing information for a Google Cloud Console project. A project has at most one associated billing account at a time (but a billing account can be assigned to multiple projects).
585///
586/// # Activities
587///
588/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
589/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
590///
591/// * [get billing info projects](ProjectGetBillingInfoCall) (response)
592/// * [update billing info projects](ProjectUpdateBillingInfoCall) (request|response)
593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
594#[serde_with::serde_as]
595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
596pub struct ProjectBillingInfo {
597 /// The resource name of the billing account associated with the project, if any. For example, `billingAccounts/012345-567890-ABCDEF`.
598 #[serde(rename = "billingAccountName")]
599 pub billing_account_name: Option<String>,
600 /// Output only. True if the project is associated with an open billing account, to which usage on the project is charged. False if the project is associated with a closed billing account, or no billing account at all, and therefore cannot use paid services.
601 #[serde(rename = "billingEnabled")]
602 pub billing_enabled: Option<bool>,
603 /// Output only. The resource name for the `ProjectBillingInfo`; has the form `projects/{project_id}/billingInfo`. For example, the resource name for the billing information for project `tokyo-rain-123` would be `projects/tokyo-rain-123/billingInfo`.
604 pub name: Option<String>,
605 /// Output only. The ID of the project that this `ProjectBillingInfo` represents, such as `tokyo-rain-123`. This is a convenience field so that you don't need to parse the `name` field to obtain a project ID.
606 #[serde(rename = "projectId")]
607 pub project_id: Option<String>,
608}
609
610impl common::RequestValue for ProjectBillingInfo {}
611impl common::ResponseResult for ProjectBillingInfo {}
612
613/// Encapsulates a single service in Google Cloud Platform.
614///
615/// # Activities
616///
617/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
618/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
619///
620/// * [skus list services](ServiceSkuListCall) (none)
621/// * [list services](ServiceListCall) (none)
622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
623#[serde_with::serde_as]
624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
625pub struct Service {
626 /// The business under which the service is offered. Ex. "businessEntities/GCP", "businessEntities/Maps"
627 #[serde(rename = "businessEntityName")]
628 pub business_entity_name: Option<String>,
629 /// A human readable display name for this service.
630 #[serde(rename = "displayName")]
631 pub display_name: Option<String>,
632 /// The resource name for the service. Example: "services/6F81-5844-456A"
633 pub name: Option<String>,
634 /// The identifier for the service. Example: "6F81-5844-456A"
635 #[serde(rename = "serviceId")]
636 pub service_id: Option<String>,
637}
638
639impl common::Resource for Service {}
640
641/// Request message for `SetIamPolicy` method.
642///
643/// # Activities
644///
645/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
646/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
647///
648/// * [set iam policy billing accounts](BillingAccountSetIamPolicyCall) (request)
649#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
650#[serde_with::serde_as]
651#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
652pub struct SetIamPolicyRequest {
653 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
654 pub policy: Option<Policy>,
655 /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
656 #[serde(rename = "updateMask")]
657 pub update_mask: Option<common::FieldMask>,
658}
659
660impl common::RequestValue for SetIamPolicyRequest {}
661
662/// Encapsulates a single SKU in Google Cloud
663///
664/// This type is not used in any activity, and only used as *part* of another schema.
665///
666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
667#[serde_with::serde_as]
668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
669pub struct Sku {
670 /// The category hierarchy of this SKU, purely for organizational purpose.
671 pub category: Option<Category>,
672 /// A human readable description of the SKU, has a maximum length of 256 characters.
673 pub description: Option<String>,
674 /// The geographic taxonomy for this sku.
675 #[serde(rename = "geoTaxonomy")]
676 pub geo_taxonomy: Option<GeoTaxonomy>,
677 /// The resource name for the SKU. Example: "services/6F81-5844-456A/skus/D041-B8A1-6E0B"
678 pub name: Option<String>,
679 /// A timeline of pricing info for this SKU in chronological order.
680 #[serde(rename = "pricingInfo")]
681 pub pricing_info: Option<Vec<PricingInfo>>,
682 /// Identifies the service provider. This is 'Google' for first party services in Google Cloud Platform.
683 #[serde(rename = "serviceProviderName")]
684 pub service_provider_name: Option<String>,
685 /// List of service regions this SKU is offered at. Example: "asia-east1" Service regions can be found at https://cloud.google.com/about/locations/
686 #[serde(rename = "serviceRegions")]
687 pub service_regions: Option<Vec<String>>,
688 /// The identifier for the SKU. Example: "D041-B8A1-6E0B"
689 #[serde(rename = "skuId")]
690 pub sku_id: Option<String>,
691}
692
693impl common::Part for Sku {}
694
695/// Request message for `TestIamPermissions` method.
696///
697/// # Activities
698///
699/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
700/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
701///
702/// * [test iam permissions billing accounts](BillingAccountTestIamPermissionCall) (request)
703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
704#[serde_with::serde_as]
705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
706pub struct TestIamPermissionsRequest {
707 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
708 pub permissions: Option<Vec<String>>,
709}
710
711impl common::RequestValue for TestIamPermissionsRequest {}
712
713/// Response message for `TestIamPermissions` method.
714///
715/// # Activities
716///
717/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
718/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
719///
720/// * [test iam permissions billing accounts](BillingAccountTestIamPermissionCall) (response)
721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
722#[serde_with::serde_as]
723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
724pub struct TestIamPermissionsResponse {
725 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
726 pub permissions: Option<Vec<String>>,
727}
728
729impl common::ResponseResult for TestIamPermissionsResponse {}
730
731/// The price rate indicating starting usage and its corresponding price.
732///
733/// This type is not used in any activity, and only used as *part* of another schema.
734///
735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
736#[serde_with::serde_as]
737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
738pub struct TierRate {
739 /// Usage is priced at this rate only after this amount. Example: start_usage_amount of 10 indicates that the usage will be priced at the unit_price after the first 10 usage_units.
740 #[serde(rename = "startUsageAmount")]
741 pub start_usage_amount: Option<f64>,
742 /// The price per unit of usage. Example: unit_price of amount $10 indicates that each unit will cost $10.
743 #[serde(rename = "unitPrice")]
744 pub unit_price: Option<Money>,
745}
746
747impl common::Part for TierRate {}
748
749// ###################
750// MethodBuilders ###
751// #################
752
753/// A builder providing access to all methods supported on *billingAccount* resources.
754/// It is not used directly, but through the [`Cloudbilling`] hub.
755///
756/// # Example
757///
758/// Instantiate a resource builder
759///
760/// ```test_harness,no_run
761/// extern crate hyper;
762/// extern crate hyper_rustls;
763/// extern crate google_cloudbilling1 as cloudbilling1;
764///
765/// # async fn dox() {
766/// use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
767///
768/// let secret: yup_oauth2::ApplicationSecret = Default::default();
769/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
770/// .with_native_roots()
771/// .unwrap()
772/// .https_only()
773/// .enable_http2()
774/// .build();
775///
776/// let executor = hyper_util::rt::TokioExecutor::new();
777/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
778/// secret,
779/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
780/// yup_oauth2::client::CustomHyperClientBuilder::from(
781/// hyper_util::client::legacy::Client::builder(executor).build(connector),
782/// ),
783/// ).build().await.unwrap();
784///
785/// let client = hyper_util::client::legacy::Client::builder(
786/// hyper_util::rt::TokioExecutor::new()
787/// )
788/// .build(
789/// hyper_rustls::HttpsConnectorBuilder::new()
790/// .with_native_roots()
791/// .unwrap()
792/// .https_or_http()
793/// .enable_http2()
794/// .build()
795/// );
796/// let mut hub = Cloudbilling::new(client, auth);
797/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
798/// // like `create(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `move_(...)`, `patch(...)`, `projects_list(...)`, `set_iam_policy(...)`, `sub_accounts_create(...)`, `sub_accounts_list(...)` and `test_iam_permissions(...)`
799/// // to build up your call.
800/// let rb = hub.billing_accounts();
801/// # }
802/// ```
803pub struct BillingAccountMethods<'a, C>
804where
805 C: 'a,
806{
807 hub: &'a Cloudbilling<C>,
808}
809
810impl<'a, C> common::MethodsBuilder for BillingAccountMethods<'a, C> {}
811
812impl<'a, C> BillingAccountMethods<'a, C> {
813 /// Create a builder to help you perform the following task:
814 ///
815 /// Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
816 ///
817 /// # Arguments
818 ///
819 /// * `name` - Required. The resource name of the billing account associated with the projects that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.
820 pub fn projects_list(&self, name: &str) -> BillingAccountProjectListCall<'a, C> {
821 BillingAccountProjectListCall {
822 hub: self.hub,
823 _name: name.to_string(),
824 _page_token: Default::default(),
825 _page_size: Default::default(),
826 _delegate: Default::default(),
827 _additional_params: Default::default(),
828 _scopes: Default::default(),
829 }
830 }
831
832 /// Create a builder to help you perform the following task:
833 ///
834 /// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
835 ///
836 /// # Arguments
837 ///
838 /// * `request` - No description provided.
839 /// * `parent` - Optional. The parent to create a billing account from. Format: - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
840 pub fn sub_accounts_create(
841 &self,
842 request: BillingAccount,
843 parent: &str,
844 ) -> BillingAccountSubAccountCreateCall<'a, C> {
845 BillingAccountSubAccountCreateCall {
846 hub: self.hub,
847 _request: request,
848 _parent: parent.to_string(),
849 _delegate: Default::default(),
850 _additional_params: Default::default(),
851 _scopes: Default::default(),
852 }
853 }
854
855 /// Create a builder to help you perform the following task:
856 ///
857 /// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
858 ///
859 /// # Arguments
860 ///
861 /// * `parent` - Optional. The parent resource to list billing accounts from. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
862 pub fn sub_accounts_list(&self, parent: &str) -> BillingAccountSubAccountListCall<'a, C> {
863 BillingAccountSubAccountListCall {
864 hub: self.hub,
865 _parent: parent.to_string(),
866 _page_token: Default::default(),
867 _page_size: Default::default(),
868 _filter: Default::default(),
869 _delegate: Default::default(),
870 _additional_params: Default::default(),
871 _scopes: Default::default(),
872 }
873 }
874
875 /// Create a builder to help you perform the following task:
876 ///
877 /// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
878 ///
879 /// # Arguments
880 ///
881 /// * `request` - No description provided.
882 pub fn create(&self, request: BillingAccount) -> BillingAccountCreateCall<'a, C> {
883 BillingAccountCreateCall {
884 hub: self.hub,
885 _request: request,
886 _parent: Default::default(),
887 _delegate: Default::default(),
888 _additional_params: Default::default(),
889 _scopes: Default::default(),
890 }
891 }
892
893 /// Create a builder to help you perform the following task:
894 ///
895 /// Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).
896 ///
897 /// # Arguments
898 ///
899 /// * `name` - Required. The resource name of the billing account to retrieve. For example, `billingAccounts/012345-567890-ABCDEF`.
900 pub fn get(&self, name: &str) -> BillingAccountGetCall<'a, C> {
901 BillingAccountGetCall {
902 hub: self.hub,
903 _name: name.to_string(),
904 _delegate: Default::default(),
905 _additional_params: Default::default(),
906 _scopes: Default::default(),
907 }
908 }
909
910 /// Create a builder to help you perform the following task:
911 ///
912 /// Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
913 ///
914 /// # Arguments
915 ///
916 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
917 pub fn get_iam_policy(&self, resource: &str) -> BillingAccountGetIamPolicyCall<'a, C> {
918 BillingAccountGetIamPolicyCall {
919 hub: self.hub,
920 _resource: resource.to_string(),
921 _options_requested_policy_version: Default::default(),
922 _delegate: Default::default(),
923 _additional_params: Default::default(),
924 _scopes: Default::default(),
925 }
926 }
927
928 /// Create a builder to help you perform the following task:
929 ///
930 /// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
931 pub fn list(&self) -> BillingAccountListCall<'a, C> {
932 BillingAccountListCall {
933 hub: self.hub,
934 _parent: Default::default(),
935 _page_token: Default::default(),
936 _page_size: Default::default(),
937 _filter: Default::default(),
938 _delegate: Default::default(),
939 _additional_params: Default::default(),
940 _scopes: Default::default(),
941 }
942 }
943
944 /// Create a builder to help you perform the following task:
945 ///
946 /// Changes which parent organization a billing account belongs to.
947 ///
948 /// # Arguments
949 ///
950 /// * `request` - No description provided.
951 /// * `name` - Required. The resource name of the billing account to move. Must be of the form `billingAccounts/{billing_account_id}`. The specified billing account cannot be a subaccount, since a subaccount always belongs to the same organization as its parent account.
952 pub fn move_(
953 &self,
954 request: MoveBillingAccountRequest,
955 name: &str,
956 ) -> BillingAccountMoveCall<'a, C> {
957 BillingAccountMoveCall {
958 hub: self.hub,
959 _request: request,
960 _name: name.to_string(),
961 _delegate: Default::default(),
962 _additional_params: Default::default(),
963 _scopes: Default::default(),
964 }
965 }
966
967 /// Create a builder to help you perform the following task:
968 ///
969 /// Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.
970 ///
971 /// # Arguments
972 ///
973 /// * `request` - No description provided.
974 /// * `name` - Required. The name of the billing account resource to be updated.
975 pub fn patch(&self, request: BillingAccount, name: &str) -> BillingAccountPatchCall<'a, C> {
976 BillingAccountPatchCall {
977 hub: self.hub,
978 _request: request,
979 _name: name.to_string(),
980 _update_mask: Default::default(),
981 _delegate: Default::default(),
982 _additional_params: Default::default(),
983 _scopes: Default::default(),
984 }
985 }
986
987 /// Create a builder to help you perform the following task:
988 ///
989 /// Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
990 ///
991 /// # Arguments
992 ///
993 /// * `request` - No description provided.
994 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
995 pub fn set_iam_policy(
996 &self,
997 request: SetIamPolicyRequest,
998 resource: &str,
999 ) -> BillingAccountSetIamPolicyCall<'a, C> {
1000 BillingAccountSetIamPolicyCall {
1001 hub: self.hub,
1002 _request: request,
1003 _resource: resource.to_string(),
1004 _delegate: Default::default(),
1005 _additional_params: Default::default(),
1006 _scopes: Default::default(),
1007 }
1008 }
1009
1010 /// Create a builder to help you perform the following task:
1011 ///
1012 /// Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.
1013 ///
1014 /// # Arguments
1015 ///
1016 /// * `request` - No description provided.
1017 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1018 pub fn test_iam_permissions(
1019 &self,
1020 request: TestIamPermissionsRequest,
1021 resource: &str,
1022 ) -> BillingAccountTestIamPermissionCall<'a, C> {
1023 BillingAccountTestIamPermissionCall {
1024 hub: self.hub,
1025 _request: request,
1026 _resource: resource.to_string(),
1027 _delegate: Default::default(),
1028 _additional_params: Default::default(),
1029 _scopes: Default::default(),
1030 }
1031 }
1032}
1033
1034/// A builder providing access to all methods supported on *organization* resources.
1035/// It is not used directly, but through the [`Cloudbilling`] hub.
1036///
1037/// # Example
1038///
1039/// Instantiate a resource builder
1040///
1041/// ```test_harness,no_run
1042/// extern crate hyper;
1043/// extern crate hyper_rustls;
1044/// extern crate google_cloudbilling1 as cloudbilling1;
1045///
1046/// # async fn dox() {
1047/// use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1048///
1049/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1050/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1051/// .with_native_roots()
1052/// .unwrap()
1053/// .https_only()
1054/// .enable_http2()
1055/// .build();
1056///
1057/// let executor = hyper_util::rt::TokioExecutor::new();
1058/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1059/// secret,
1060/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1061/// yup_oauth2::client::CustomHyperClientBuilder::from(
1062/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1063/// ),
1064/// ).build().await.unwrap();
1065///
1066/// let client = hyper_util::client::legacy::Client::builder(
1067/// hyper_util::rt::TokioExecutor::new()
1068/// )
1069/// .build(
1070/// hyper_rustls::HttpsConnectorBuilder::new()
1071/// .with_native_roots()
1072/// .unwrap()
1073/// .https_or_http()
1074/// .enable_http2()
1075/// .build()
1076/// );
1077/// let mut hub = Cloudbilling::new(client, auth);
1078/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1079/// // like `billing_accounts_create(...)`, `billing_accounts_list(...)` and `billing_accounts_move(...)`
1080/// // to build up your call.
1081/// let rb = hub.organizations();
1082/// # }
1083/// ```
1084pub struct OrganizationMethods<'a, C>
1085where
1086 C: 'a,
1087{
1088 hub: &'a Cloudbilling<C>,
1089}
1090
1091impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1092
1093impl<'a, C> OrganizationMethods<'a, C> {
1094 /// Create a builder to help you perform the following task:
1095 ///
1096 /// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
1097 ///
1098 /// # Arguments
1099 ///
1100 /// * `request` - No description provided.
1101 /// * `parent` - Optional. The parent to create a billing account from. Format: - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
1102 pub fn billing_accounts_create(
1103 &self,
1104 request: BillingAccount,
1105 parent: &str,
1106 ) -> OrganizationBillingAccountCreateCall<'a, C> {
1107 OrganizationBillingAccountCreateCall {
1108 hub: self.hub,
1109 _request: request,
1110 _parent: parent.to_string(),
1111 _delegate: Default::default(),
1112 _additional_params: Default::default(),
1113 _scopes: Default::default(),
1114 }
1115 }
1116
1117 /// Create a builder to help you perform the following task:
1118 ///
1119 /// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
1120 ///
1121 /// # Arguments
1122 ///
1123 /// * `parent` - Optional. The parent resource to list billing accounts from. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
1124 pub fn billing_accounts_list(&self, parent: &str) -> OrganizationBillingAccountListCall<'a, C> {
1125 OrganizationBillingAccountListCall {
1126 hub: self.hub,
1127 _parent: parent.to_string(),
1128 _page_token: Default::default(),
1129 _page_size: Default::default(),
1130 _filter: Default::default(),
1131 _delegate: Default::default(),
1132 _additional_params: Default::default(),
1133 _scopes: Default::default(),
1134 }
1135 }
1136
1137 /// Create a builder to help you perform the following task:
1138 ///
1139 /// Changes which parent organization a billing account belongs to.
1140 ///
1141 /// # Arguments
1142 ///
1143 /// * `destinationParent` - Required. The resource name of the Organization to move the billing account under. Must be of the form `organizations/{organization_id}`.
1144 /// * `name` - Required. The resource name of the billing account to move. Must be of the form `billingAccounts/{billing_account_id}`. The specified billing account cannot be a subaccount, since a subaccount always belongs to the same organization as its parent account.
1145 pub fn billing_accounts_move(
1146 &self,
1147 destination_parent: &str,
1148 name: &str,
1149 ) -> OrganizationBillingAccountMoveCall<'a, C> {
1150 OrganizationBillingAccountMoveCall {
1151 hub: self.hub,
1152 _destination_parent: destination_parent.to_string(),
1153 _name: name.to_string(),
1154 _delegate: Default::default(),
1155 _additional_params: Default::default(),
1156 _scopes: Default::default(),
1157 }
1158 }
1159}
1160
1161/// A builder providing access to all methods supported on *project* resources.
1162/// It is not used directly, but through the [`Cloudbilling`] hub.
1163///
1164/// # Example
1165///
1166/// Instantiate a resource builder
1167///
1168/// ```test_harness,no_run
1169/// extern crate hyper;
1170/// extern crate hyper_rustls;
1171/// extern crate google_cloudbilling1 as cloudbilling1;
1172///
1173/// # async fn dox() {
1174/// use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1175///
1176/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1177/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1178/// .with_native_roots()
1179/// .unwrap()
1180/// .https_only()
1181/// .enable_http2()
1182/// .build();
1183///
1184/// let executor = hyper_util::rt::TokioExecutor::new();
1185/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1186/// secret,
1187/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1188/// yup_oauth2::client::CustomHyperClientBuilder::from(
1189/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1190/// ),
1191/// ).build().await.unwrap();
1192///
1193/// let client = hyper_util::client::legacy::Client::builder(
1194/// hyper_util::rt::TokioExecutor::new()
1195/// )
1196/// .build(
1197/// hyper_rustls::HttpsConnectorBuilder::new()
1198/// .with_native_roots()
1199/// .unwrap()
1200/// .https_or_http()
1201/// .enable_http2()
1202/// .build()
1203/// );
1204/// let mut hub = Cloudbilling::new(client, auth);
1205/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1206/// // like `get_billing_info(...)` and `update_billing_info(...)`
1207/// // to build up your call.
1208/// let rb = hub.projects();
1209/// # }
1210/// ```
1211pub struct ProjectMethods<'a, C>
1212where
1213 C: 'a,
1214{
1215 hub: &'a Cloudbilling<C>,
1216}
1217
1218impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1219
1220impl<'a, C> ProjectMethods<'a, C> {
1221 /// Create a builder to help you perform the following task:
1222 ///
1223 /// Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.
1224 ///
1225 /// # Arguments
1226 ///
1227 /// * `name` - Required. The resource name of the project for which billing information is retrieved. For example, `projects/tokyo-rain-123`.
1228 pub fn get_billing_info(&self, name: &str) -> ProjectGetBillingInfoCall<'a, C> {
1229 ProjectGetBillingInfoCall {
1230 hub: self.hub,
1231 _name: name.to_string(),
1232 _delegate: Default::default(),
1233 _additional_params: Default::default(),
1234 _scopes: Default::default(),
1235 }
1236 }
1237
1238 /// Create a builder to help you perform the following task:
1239 ///
1240 /// Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.
1241 ///
1242 /// # Arguments
1243 ///
1244 /// * `request` - No description provided.
1245 /// * `name` - Required. The resource name of the project associated with the billing information that you want to update. For example, `projects/tokyo-rain-123`.
1246 pub fn update_billing_info(
1247 &self,
1248 request: ProjectBillingInfo,
1249 name: &str,
1250 ) -> ProjectUpdateBillingInfoCall<'a, C> {
1251 ProjectUpdateBillingInfoCall {
1252 hub: self.hub,
1253 _request: request,
1254 _name: name.to_string(),
1255 _delegate: Default::default(),
1256 _additional_params: Default::default(),
1257 _scopes: Default::default(),
1258 }
1259 }
1260}
1261
1262/// A builder providing access to all methods supported on *service* resources.
1263/// It is not used directly, but through the [`Cloudbilling`] hub.
1264///
1265/// # Example
1266///
1267/// Instantiate a resource builder
1268///
1269/// ```test_harness,no_run
1270/// extern crate hyper;
1271/// extern crate hyper_rustls;
1272/// extern crate google_cloudbilling1 as cloudbilling1;
1273///
1274/// # async fn dox() {
1275/// use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1276///
1277/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1278/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1279/// .with_native_roots()
1280/// .unwrap()
1281/// .https_only()
1282/// .enable_http2()
1283/// .build();
1284///
1285/// let executor = hyper_util::rt::TokioExecutor::new();
1286/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1287/// secret,
1288/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1289/// yup_oauth2::client::CustomHyperClientBuilder::from(
1290/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1291/// ),
1292/// ).build().await.unwrap();
1293///
1294/// let client = hyper_util::client::legacy::Client::builder(
1295/// hyper_util::rt::TokioExecutor::new()
1296/// )
1297/// .build(
1298/// hyper_rustls::HttpsConnectorBuilder::new()
1299/// .with_native_roots()
1300/// .unwrap()
1301/// .https_or_http()
1302/// .enable_http2()
1303/// .build()
1304/// );
1305/// let mut hub = Cloudbilling::new(client, auth);
1306/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1307/// // like `list(...)` and `skus_list(...)`
1308/// // to build up your call.
1309/// let rb = hub.services();
1310/// # }
1311/// ```
1312pub struct ServiceMethods<'a, C>
1313where
1314 C: 'a,
1315{
1316 hub: &'a Cloudbilling<C>,
1317}
1318
1319impl<'a, C> common::MethodsBuilder for ServiceMethods<'a, C> {}
1320
1321impl<'a, C> ServiceMethods<'a, C> {
1322 /// Create a builder to help you perform the following task:
1323 ///
1324 /// Lists all publicly available SKUs for a given cloud service.
1325 ///
1326 /// # Arguments
1327 ///
1328 /// * `parent` - Required. The name of the service. Example: "services/6F81-5844-456A"
1329 pub fn skus_list(&self, parent: &str) -> ServiceSkuListCall<'a, C> {
1330 ServiceSkuListCall {
1331 hub: self.hub,
1332 _parent: parent.to_string(),
1333 _start_time: Default::default(),
1334 _page_token: Default::default(),
1335 _page_size: Default::default(),
1336 _end_time: Default::default(),
1337 _currency_code: Default::default(),
1338 _delegate: Default::default(),
1339 _additional_params: Default::default(),
1340 _scopes: Default::default(),
1341 }
1342 }
1343
1344 /// Create a builder to help you perform the following task:
1345 ///
1346 /// Lists all public cloud services.
1347 pub fn list(&self) -> ServiceListCall<'a, C> {
1348 ServiceListCall {
1349 hub: self.hub,
1350 _page_token: Default::default(),
1351 _page_size: Default::default(),
1352 _delegate: Default::default(),
1353 _additional_params: Default::default(),
1354 _scopes: Default::default(),
1355 }
1356 }
1357}
1358
1359// ###################
1360// CallBuilders ###
1361// #################
1362
1363/// Lists the projects associated with a billing account. The current authenticated user must have the `billing.resourceAssociations.list` IAM permission, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
1364///
1365/// A builder for the *projects.list* method supported by a *billingAccount* resource.
1366/// It is not used directly, but through a [`BillingAccountMethods`] instance.
1367///
1368/// # Example
1369///
1370/// Instantiate a resource method builder
1371///
1372/// ```test_harness,no_run
1373/// # extern crate hyper;
1374/// # extern crate hyper_rustls;
1375/// # extern crate google_cloudbilling1 as cloudbilling1;
1376/// # async fn dox() {
1377/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1378///
1379/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1380/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1381/// # .with_native_roots()
1382/// # .unwrap()
1383/// # .https_only()
1384/// # .enable_http2()
1385/// # .build();
1386///
1387/// # let executor = hyper_util::rt::TokioExecutor::new();
1388/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1389/// # secret,
1390/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1391/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1392/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1393/// # ),
1394/// # ).build().await.unwrap();
1395///
1396/// # let client = hyper_util::client::legacy::Client::builder(
1397/// # hyper_util::rt::TokioExecutor::new()
1398/// # )
1399/// # .build(
1400/// # hyper_rustls::HttpsConnectorBuilder::new()
1401/// # .with_native_roots()
1402/// # .unwrap()
1403/// # .https_or_http()
1404/// # .enable_http2()
1405/// # .build()
1406/// # );
1407/// # let mut hub = Cloudbilling::new(client, auth);
1408/// // You can configure optional parameters by calling the respective setters at will, and
1409/// // execute the final call using `doit()`.
1410/// // Values shown here are possibly random and not representative !
1411/// let result = hub.billing_accounts().projects_list("name")
1412/// .page_token("gubergren")
1413/// .page_size(-51)
1414/// .doit().await;
1415/// # }
1416/// ```
1417pub struct BillingAccountProjectListCall<'a, C>
1418where
1419 C: 'a,
1420{
1421 hub: &'a Cloudbilling<C>,
1422 _name: String,
1423 _page_token: Option<String>,
1424 _page_size: Option<i32>,
1425 _delegate: Option<&'a mut dyn common::Delegate>,
1426 _additional_params: HashMap<String, String>,
1427 _scopes: BTreeSet<String>,
1428}
1429
1430impl<'a, C> common::CallBuilder for BillingAccountProjectListCall<'a, C> {}
1431
1432impl<'a, C> BillingAccountProjectListCall<'a, C>
1433where
1434 C: common::Connector,
1435{
1436 /// Perform the operation you have build so far.
1437 pub async fn doit(
1438 mut self,
1439 ) -> common::Result<(common::Response, ListProjectBillingInfoResponse)> {
1440 use std::borrow::Cow;
1441 use std::io::{Read, Seek};
1442
1443 use common::{url::Params, ToParts};
1444 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1445
1446 let mut dd = common::DefaultDelegate;
1447 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1448 dlg.begin(common::MethodInfo {
1449 id: "cloudbilling.billingAccounts.projects.list",
1450 http_method: hyper::Method::GET,
1451 });
1452
1453 for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
1454 if self._additional_params.contains_key(field) {
1455 dlg.finished(false);
1456 return Err(common::Error::FieldClash(field));
1457 }
1458 }
1459
1460 let mut params = Params::with_capacity(5 + self._additional_params.len());
1461 params.push("name", self._name);
1462 if let Some(value) = self._page_token.as_ref() {
1463 params.push("pageToken", value);
1464 }
1465 if let Some(value) = self._page_size.as_ref() {
1466 params.push("pageSize", value.to_string());
1467 }
1468
1469 params.extend(self._additional_params.iter());
1470
1471 params.push("alt", "json");
1472 let mut url = self.hub._base_url.clone() + "v1/{+name}/projects";
1473 if self._scopes.is_empty() {
1474 self._scopes
1475 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
1476 }
1477
1478 #[allow(clippy::single_element_loop)]
1479 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1480 url = params.uri_replacement(url, param_name, find_this, true);
1481 }
1482 {
1483 let to_remove = ["name"];
1484 params.remove_params(&to_remove);
1485 }
1486
1487 let url = params.parse_with_url(&url);
1488
1489 loop {
1490 let token = match self
1491 .hub
1492 .auth
1493 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1494 .await
1495 {
1496 Ok(token) => token,
1497 Err(e) => match dlg.token(e) {
1498 Ok(token) => token,
1499 Err(e) => {
1500 dlg.finished(false);
1501 return Err(common::Error::MissingToken(e));
1502 }
1503 },
1504 };
1505 let mut req_result = {
1506 let client = &self.hub.client;
1507 dlg.pre_request();
1508 let mut req_builder = hyper::Request::builder()
1509 .method(hyper::Method::GET)
1510 .uri(url.as_str())
1511 .header(USER_AGENT, self.hub._user_agent.clone());
1512
1513 if let Some(token) = token.as_ref() {
1514 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1515 }
1516
1517 let request = req_builder
1518 .header(CONTENT_LENGTH, 0_u64)
1519 .body(common::to_body::<String>(None));
1520
1521 client.request(request.unwrap()).await
1522 };
1523
1524 match req_result {
1525 Err(err) => {
1526 if let common::Retry::After(d) = dlg.http_error(&err) {
1527 sleep(d).await;
1528 continue;
1529 }
1530 dlg.finished(false);
1531 return Err(common::Error::HttpError(err));
1532 }
1533 Ok(res) => {
1534 let (mut parts, body) = res.into_parts();
1535 let mut body = common::Body::new(body);
1536 if !parts.status.is_success() {
1537 let bytes = common::to_bytes(body).await.unwrap_or_default();
1538 let error = serde_json::from_str(&common::to_string(&bytes));
1539 let response = common::to_response(parts, bytes.into());
1540
1541 if let common::Retry::After(d) =
1542 dlg.http_failure(&response, error.as_ref().ok())
1543 {
1544 sleep(d).await;
1545 continue;
1546 }
1547
1548 dlg.finished(false);
1549
1550 return Err(match error {
1551 Ok(value) => common::Error::BadRequest(value),
1552 _ => common::Error::Failure(response),
1553 });
1554 }
1555 let response = {
1556 let bytes = common::to_bytes(body).await.unwrap_or_default();
1557 let encoded = common::to_string(&bytes);
1558 match serde_json::from_str(&encoded) {
1559 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1560 Err(error) => {
1561 dlg.response_json_decode_error(&encoded, &error);
1562 return Err(common::Error::JsonDecodeError(
1563 encoded.to_string(),
1564 error,
1565 ));
1566 }
1567 }
1568 };
1569
1570 dlg.finished(true);
1571 return Ok(response);
1572 }
1573 }
1574 }
1575 }
1576
1577 /// Required. The resource name of the billing account associated with the projects that you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.
1578 ///
1579 /// Sets the *name* path property to the given value.
1580 ///
1581 /// Even though the property as already been set when instantiating this call,
1582 /// we provide this method for API completeness.
1583 pub fn name(mut self, new_value: &str) -> BillingAccountProjectListCall<'a, C> {
1584 self._name = new_value.to_string();
1585 self
1586 }
1587 /// A token identifying a page of results to be returned. This should be a `next_page_token` value returned from a previous `ListProjectBillingInfo` call. If unspecified, the first page of results is returned.
1588 ///
1589 /// Sets the *page token* query property to the given value.
1590 pub fn page_token(mut self, new_value: &str) -> BillingAccountProjectListCall<'a, C> {
1591 self._page_token = Some(new_value.to_string());
1592 self
1593 }
1594 /// Requested page size. The maximum page size is 100; this is also the default.
1595 ///
1596 /// Sets the *page size* query property to the given value.
1597 pub fn page_size(mut self, new_value: i32) -> BillingAccountProjectListCall<'a, C> {
1598 self._page_size = Some(new_value);
1599 self
1600 }
1601 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1602 /// while executing the actual API request.
1603 ///
1604 /// ````text
1605 /// It should be used to handle progress information, and to implement a certain level of resilience.
1606 /// ````
1607 ///
1608 /// Sets the *delegate* property to the given value.
1609 pub fn delegate(
1610 mut self,
1611 new_value: &'a mut dyn common::Delegate,
1612 ) -> BillingAccountProjectListCall<'a, C> {
1613 self._delegate = Some(new_value);
1614 self
1615 }
1616
1617 /// Set any additional parameter of the query string used in the request.
1618 /// It should be used to set parameters which are not yet available through their own
1619 /// setters.
1620 ///
1621 /// Please note that this method must not be used to set any of the known parameters
1622 /// which have their own setter method. If done anyway, the request will fail.
1623 ///
1624 /// # Additional Parameters
1625 ///
1626 /// * *$.xgafv* (query-string) - V1 error format.
1627 /// * *access_token* (query-string) - OAuth access token.
1628 /// * *alt* (query-string) - Data format for response.
1629 /// * *callback* (query-string) - JSONP
1630 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1631 /// * *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.
1632 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1633 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1634 /// * *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.
1635 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1636 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1637 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountProjectListCall<'a, C>
1638 where
1639 T: AsRef<str>,
1640 {
1641 self._additional_params
1642 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1643 self
1644 }
1645
1646 /// Identifies the authorization scope for the method you are building.
1647 ///
1648 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1649 /// [`Scope::CloudBillingReadonly`].
1650 ///
1651 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1652 /// tokens for more than one scope.
1653 ///
1654 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1655 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1656 /// sufficient, a read-write scope will do as well.
1657 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountProjectListCall<'a, C>
1658 where
1659 St: AsRef<str>,
1660 {
1661 self._scopes.insert(String::from(scope.as_ref()));
1662 self
1663 }
1664 /// Identifies the authorization scope(s) for the method you are building.
1665 ///
1666 /// See [`Self::add_scope()`] for details.
1667 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountProjectListCall<'a, C>
1668 where
1669 I: IntoIterator<Item = St>,
1670 St: AsRef<str>,
1671 {
1672 self._scopes
1673 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1674 self
1675 }
1676
1677 /// Removes all scopes, and no default scope will be used either.
1678 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1679 /// for details).
1680 pub fn clear_scopes(mut self) -> BillingAccountProjectListCall<'a, C> {
1681 self._scopes.clear();
1682 self
1683 }
1684}
1685
1686/// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
1687///
1688/// A builder for the *subAccounts.create* method supported by a *billingAccount* resource.
1689/// It is not used directly, but through a [`BillingAccountMethods`] instance.
1690///
1691/// # Example
1692///
1693/// Instantiate a resource method builder
1694///
1695/// ```test_harness,no_run
1696/// # extern crate hyper;
1697/// # extern crate hyper_rustls;
1698/// # extern crate google_cloudbilling1 as cloudbilling1;
1699/// use cloudbilling1::api::BillingAccount;
1700/// # async fn dox() {
1701/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1702///
1703/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1704/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1705/// # .with_native_roots()
1706/// # .unwrap()
1707/// # .https_only()
1708/// # .enable_http2()
1709/// # .build();
1710///
1711/// # let executor = hyper_util::rt::TokioExecutor::new();
1712/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1713/// # secret,
1714/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1715/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1716/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1717/// # ),
1718/// # ).build().await.unwrap();
1719///
1720/// # let client = hyper_util::client::legacy::Client::builder(
1721/// # hyper_util::rt::TokioExecutor::new()
1722/// # )
1723/// # .build(
1724/// # hyper_rustls::HttpsConnectorBuilder::new()
1725/// # .with_native_roots()
1726/// # .unwrap()
1727/// # .https_or_http()
1728/// # .enable_http2()
1729/// # .build()
1730/// # );
1731/// # let mut hub = Cloudbilling::new(client, auth);
1732/// // As the method needs a request, you would usually fill it with the desired information
1733/// // into the respective structure. Some of the parts shown here might not be applicable !
1734/// // Values shown here are possibly random and not representative !
1735/// let mut req = BillingAccount::default();
1736///
1737/// // You can configure optional parameters by calling the respective setters at will, and
1738/// // execute the final call using `doit()`.
1739/// // Values shown here are possibly random and not representative !
1740/// let result = hub.billing_accounts().sub_accounts_create(req, "parent")
1741/// .doit().await;
1742/// # }
1743/// ```
1744pub struct BillingAccountSubAccountCreateCall<'a, C>
1745where
1746 C: 'a,
1747{
1748 hub: &'a Cloudbilling<C>,
1749 _request: BillingAccount,
1750 _parent: String,
1751 _delegate: Option<&'a mut dyn common::Delegate>,
1752 _additional_params: HashMap<String, String>,
1753 _scopes: BTreeSet<String>,
1754}
1755
1756impl<'a, C> common::CallBuilder for BillingAccountSubAccountCreateCall<'a, C> {}
1757
1758impl<'a, C> BillingAccountSubAccountCreateCall<'a, C>
1759where
1760 C: common::Connector,
1761{
1762 /// Perform the operation you have build so far.
1763 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
1764 use std::borrow::Cow;
1765 use std::io::{Read, Seek};
1766
1767 use common::{url::Params, ToParts};
1768 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1769
1770 let mut dd = common::DefaultDelegate;
1771 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1772 dlg.begin(common::MethodInfo {
1773 id: "cloudbilling.billingAccounts.subAccounts.create",
1774 http_method: hyper::Method::POST,
1775 });
1776
1777 for &field in ["alt", "parent"].iter() {
1778 if self._additional_params.contains_key(field) {
1779 dlg.finished(false);
1780 return Err(common::Error::FieldClash(field));
1781 }
1782 }
1783
1784 let mut params = Params::with_capacity(4 + self._additional_params.len());
1785 params.push("parent", self._parent);
1786
1787 params.extend(self._additional_params.iter());
1788
1789 params.push("alt", "json");
1790 let mut url = self.hub._base_url.clone() + "v1/{+parent}/subAccounts";
1791 if self._scopes.is_empty() {
1792 self._scopes
1793 .insert(Scope::CloudPlatform.as_ref().to_string());
1794 }
1795
1796 #[allow(clippy::single_element_loop)]
1797 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1798 url = params.uri_replacement(url, param_name, find_this, true);
1799 }
1800 {
1801 let to_remove = ["parent"];
1802 params.remove_params(&to_remove);
1803 }
1804
1805 let url = params.parse_with_url(&url);
1806
1807 let mut json_mime_type = mime::APPLICATION_JSON;
1808 let mut request_value_reader = {
1809 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1810 common::remove_json_null_values(&mut value);
1811 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1812 serde_json::to_writer(&mut dst, &value).unwrap();
1813 dst
1814 };
1815 let request_size = request_value_reader
1816 .seek(std::io::SeekFrom::End(0))
1817 .unwrap();
1818 request_value_reader
1819 .seek(std::io::SeekFrom::Start(0))
1820 .unwrap();
1821
1822 loop {
1823 let token = match self
1824 .hub
1825 .auth
1826 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1827 .await
1828 {
1829 Ok(token) => token,
1830 Err(e) => match dlg.token(e) {
1831 Ok(token) => token,
1832 Err(e) => {
1833 dlg.finished(false);
1834 return Err(common::Error::MissingToken(e));
1835 }
1836 },
1837 };
1838 request_value_reader
1839 .seek(std::io::SeekFrom::Start(0))
1840 .unwrap();
1841 let mut req_result = {
1842 let client = &self.hub.client;
1843 dlg.pre_request();
1844 let mut req_builder = hyper::Request::builder()
1845 .method(hyper::Method::POST)
1846 .uri(url.as_str())
1847 .header(USER_AGENT, self.hub._user_agent.clone());
1848
1849 if let Some(token) = token.as_ref() {
1850 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1851 }
1852
1853 let request = req_builder
1854 .header(CONTENT_TYPE, json_mime_type.to_string())
1855 .header(CONTENT_LENGTH, request_size as u64)
1856 .body(common::to_body(
1857 request_value_reader.get_ref().clone().into(),
1858 ));
1859
1860 client.request(request.unwrap()).await
1861 };
1862
1863 match req_result {
1864 Err(err) => {
1865 if let common::Retry::After(d) = dlg.http_error(&err) {
1866 sleep(d).await;
1867 continue;
1868 }
1869 dlg.finished(false);
1870 return Err(common::Error::HttpError(err));
1871 }
1872 Ok(res) => {
1873 let (mut parts, body) = res.into_parts();
1874 let mut body = common::Body::new(body);
1875 if !parts.status.is_success() {
1876 let bytes = common::to_bytes(body).await.unwrap_or_default();
1877 let error = serde_json::from_str(&common::to_string(&bytes));
1878 let response = common::to_response(parts, bytes.into());
1879
1880 if let common::Retry::After(d) =
1881 dlg.http_failure(&response, error.as_ref().ok())
1882 {
1883 sleep(d).await;
1884 continue;
1885 }
1886
1887 dlg.finished(false);
1888
1889 return Err(match error {
1890 Ok(value) => common::Error::BadRequest(value),
1891 _ => common::Error::Failure(response),
1892 });
1893 }
1894 let response = {
1895 let bytes = common::to_bytes(body).await.unwrap_or_default();
1896 let encoded = common::to_string(&bytes);
1897 match serde_json::from_str(&encoded) {
1898 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1899 Err(error) => {
1900 dlg.response_json_decode_error(&encoded, &error);
1901 return Err(common::Error::JsonDecodeError(
1902 encoded.to_string(),
1903 error,
1904 ));
1905 }
1906 }
1907 };
1908
1909 dlg.finished(true);
1910 return Ok(response);
1911 }
1912 }
1913 }
1914 }
1915
1916 ///
1917 /// Sets the *request* property to the given value.
1918 ///
1919 /// Even though the property as already been set when instantiating this call,
1920 /// we provide this method for API completeness.
1921 pub fn request(
1922 mut self,
1923 new_value: BillingAccount,
1924 ) -> BillingAccountSubAccountCreateCall<'a, C> {
1925 self._request = new_value;
1926 self
1927 }
1928 /// Optional. The parent to create a billing account from. Format: - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
1929 ///
1930 /// Sets the *parent* path property to the given value.
1931 ///
1932 /// Even though the property as already been set when instantiating this call,
1933 /// we provide this method for API completeness.
1934 pub fn parent(mut self, new_value: &str) -> BillingAccountSubAccountCreateCall<'a, C> {
1935 self._parent = new_value.to_string();
1936 self
1937 }
1938 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1939 /// while executing the actual API request.
1940 ///
1941 /// ````text
1942 /// It should be used to handle progress information, and to implement a certain level of resilience.
1943 /// ````
1944 ///
1945 /// Sets the *delegate* property to the given value.
1946 pub fn delegate(
1947 mut self,
1948 new_value: &'a mut dyn common::Delegate,
1949 ) -> BillingAccountSubAccountCreateCall<'a, C> {
1950 self._delegate = Some(new_value);
1951 self
1952 }
1953
1954 /// Set any additional parameter of the query string used in the request.
1955 /// It should be used to set parameters which are not yet available through their own
1956 /// setters.
1957 ///
1958 /// Please note that this method must not be used to set any of the known parameters
1959 /// which have their own setter method. If done anyway, the request will fail.
1960 ///
1961 /// # Additional Parameters
1962 ///
1963 /// * *$.xgafv* (query-string) - V1 error format.
1964 /// * *access_token* (query-string) - OAuth access token.
1965 /// * *alt* (query-string) - Data format for response.
1966 /// * *callback* (query-string) - JSONP
1967 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1968 /// * *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.
1969 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1970 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1971 /// * *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.
1972 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1973 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1974 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountSubAccountCreateCall<'a, C>
1975 where
1976 T: AsRef<str>,
1977 {
1978 self._additional_params
1979 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1980 self
1981 }
1982
1983 /// Identifies the authorization scope for the method you are building.
1984 ///
1985 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1986 /// [`Scope::CloudPlatform`].
1987 ///
1988 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1989 /// tokens for more than one scope.
1990 ///
1991 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1992 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1993 /// sufficient, a read-write scope will do as well.
1994 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountSubAccountCreateCall<'a, C>
1995 where
1996 St: AsRef<str>,
1997 {
1998 self._scopes.insert(String::from(scope.as_ref()));
1999 self
2000 }
2001 /// Identifies the authorization scope(s) for the method you are building.
2002 ///
2003 /// See [`Self::add_scope()`] for details.
2004 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountSubAccountCreateCall<'a, C>
2005 where
2006 I: IntoIterator<Item = St>,
2007 St: AsRef<str>,
2008 {
2009 self._scopes
2010 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2011 self
2012 }
2013
2014 /// Removes all scopes, and no default scope will be used either.
2015 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2016 /// for details).
2017 pub fn clear_scopes(mut self) -> BillingAccountSubAccountCreateCall<'a, C> {
2018 self._scopes.clear();
2019 self
2020 }
2021}
2022
2023/// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
2024///
2025/// A builder for the *subAccounts.list* method supported by a *billingAccount* resource.
2026/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2027///
2028/// # Example
2029///
2030/// Instantiate a resource method builder
2031///
2032/// ```test_harness,no_run
2033/// # extern crate hyper;
2034/// # extern crate hyper_rustls;
2035/// # extern crate google_cloudbilling1 as cloudbilling1;
2036/// # async fn dox() {
2037/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2038///
2039/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2040/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2041/// # .with_native_roots()
2042/// # .unwrap()
2043/// # .https_only()
2044/// # .enable_http2()
2045/// # .build();
2046///
2047/// # let executor = hyper_util::rt::TokioExecutor::new();
2048/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2049/// # secret,
2050/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2051/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2052/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2053/// # ),
2054/// # ).build().await.unwrap();
2055///
2056/// # let client = hyper_util::client::legacy::Client::builder(
2057/// # hyper_util::rt::TokioExecutor::new()
2058/// # )
2059/// # .build(
2060/// # hyper_rustls::HttpsConnectorBuilder::new()
2061/// # .with_native_roots()
2062/// # .unwrap()
2063/// # .https_or_http()
2064/// # .enable_http2()
2065/// # .build()
2066/// # );
2067/// # let mut hub = Cloudbilling::new(client, auth);
2068/// // You can configure optional parameters by calling the respective setters at will, and
2069/// // execute the final call using `doit()`.
2070/// // Values shown here are possibly random and not representative !
2071/// let result = hub.billing_accounts().sub_accounts_list("parent")
2072/// .page_token("dolor")
2073/// .page_size(-17)
2074/// .filter("ipsum")
2075/// .doit().await;
2076/// # }
2077/// ```
2078pub struct BillingAccountSubAccountListCall<'a, C>
2079where
2080 C: 'a,
2081{
2082 hub: &'a Cloudbilling<C>,
2083 _parent: String,
2084 _page_token: Option<String>,
2085 _page_size: Option<i32>,
2086 _filter: Option<String>,
2087 _delegate: Option<&'a mut dyn common::Delegate>,
2088 _additional_params: HashMap<String, String>,
2089 _scopes: BTreeSet<String>,
2090}
2091
2092impl<'a, C> common::CallBuilder for BillingAccountSubAccountListCall<'a, C> {}
2093
2094impl<'a, C> BillingAccountSubAccountListCall<'a, C>
2095where
2096 C: common::Connector,
2097{
2098 /// Perform the operation you have build so far.
2099 pub async fn doit(mut self) -> common::Result<(common::Response, ListBillingAccountsResponse)> {
2100 use std::borrow::Cow;
2101 use std::io::{Read, Seek};
2102
2103 use common::{url::Params, ToParts};
2104 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2105
2106 let mut dd = common::DefaultDelegate;
2107 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2108 dlg.begin(common::MethodInfo {
2109 id: "cloudbilling.billingAccounts.subAccounts.list",
2110 http_method: hyper::Method::GET,
2111 });
2112
2113 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
2114 if self._additional_params.contains_key(field) {
2115 dlg.finished(false);
2116 return Err(common::Error::FieldClash(field));
2117 }
2118 }
2119
2120 let mut params = Params::with_capacity(6 + self._additional_params.len());
2121 params.push("parent", self._parent);
2122 if let Some(value) = self._page_token.as_ref() {
2123 params.push("pageToken", value);
2124 }
2125 if let Some(value) = self._page_size.as_ref() {
2126 params.push("pageSize", value.to_string());
2127 }
2128 if let Some(value) = self._filter.as_ref() {
2129 params.push("filter", value);
2130 }
2131
2132 params.extend(self._additional_params.iter());
2133
2134 params.push("alt", "json");
2135 let mut url = self.hub._base_url.clone() + "v1/{+parent}/subAccounts";
2136 if self._scopes.is_empty() {
2137 self._scopes
2138 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
2139 }
2140
2141 #[allow(clippy::single_element_loop)]
2142 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2143 url = params.uri_replacement(url, param_name, find_this, true);
2144 }
2145 {
2146 let to_remove = ["parent"];
2147 params.remove_params(&to_remove);
2148 }
2149
2150 let url = params.parse_with_url(&url);
2151
2152 loop {
2153 let token = match self
2154 .hub
2155 .auth
2156 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2157 .await
2158 {
2159 Ok(token) => token,
2160 Err(e) => match dlg.token(e) {
2161 Ok(token) => token,
2162 Err(e) => {
2163 dlg.finished(false);
2164 return Err(common::Error::MissingToken(e));
2165 }
2166 },
2167 };
2168 let mut req_result = {
2169 let client = &self.hub.client;
2170 dlg.pre_request();
2171 let mut req_builder = hyper::Request::builder()
2172 .method(hyper::Method::GET)
2173 .uri(url.as_str())
2174 .header(USER_AGENT, self.hub._user_agent.clone());
2175
2176 if let Some(token) = token.as_ref() {
2177 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2178 }
2179
2180 let request = req_builder
2181 .header(CONTENT_LENGTH, 0_u64)
2182 .body(common::to_body::<String>(None));
2183
2184 client.request(request.unwrap()).await
2185 };
2186
2187 match req_result {
2188 Err(err) => {
2189 if let common::Retry::After(d) = dlg.http_error(&err) {
2190 sleep(d).await;
2191 continue;
2192 }
2193 dlg.finished(false);
2194 return Err(common::Error::HttpError(err));
2195 }
2196 Ok(res) => {
2197 let (mut parts, body) = res.into_parts();
2198 let mut body = common::Body::new(body);
2199 if !parts.status.is_success() {
2200 let bytes = common::to_bytes(body).await.unwrap_or_default();
2201 let error = serde_json::from_str(&common::to_string(&bytes));
2202 let response = common::to_response(parts, bytes.into());
2203
2204 if let common::Retry::After(d) =
2205 dlg.http_failure(&response, error.as_ref().ok())
2206 {
2207 sleep(d).await;
2208 continue;
2209 }
2210
2211 dlg.finished(false);
2212
2213 return Err(match error {
2214 Ok(value) => common::Error::BadRequest(value),
2215 _ => common::Error::Failure(response),
2216 });
2217 }
2218 let response = {
2219 let bytes = common::to_bytes(body).await.unwrap_or_default();
2220 let encoded = common::to_string(&bytes);
2221 match serde_json::from_str(&encoded) {
2222 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2223 Err(error) => {
2224 dlg.response_json_decode_error(&encoded, &error);
2225 return Err(common::Error::JsonDecodeError(
2226 encoded.to_string(),
2227 error,
2228 ));
2229 }
2230 }
2231 };
2232
2233 dlg.finished(true);
2234 return Ok(response);
2235 }
2236 }
2237 }
2238 }
2239
2240 /// Optional. The parent resource to list billing accounts from. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
2241 ///
2242 /// Sets the *parent* path property to the given value.
2243 ///
2244 /// Even though the property as already been set when instantiating this call,
2245 /// we provide this method for API completeness.
2246 pub fn parent(mut self, new_value: &str) -> BillingAccountSubAccountListCall<'a, C> {
2247 self._parent = new_value.to_string();
2248 self
2249 }
2250 /// A token identifying a page of results to return. This should be a `next_page_token` value returned from a previous `ListBillingAccounts` call. If unspecified, the first page of results is returned.
2251 ///
2252 /// Sets the *page token* query property to the given value.
2253 pub fn page_token(mut self, new_value: &str) -> BillingAccountSubAccountListCall<'a, C> {
2254 self._page_token = Some(new_value.to_string());
2255 self
2256 }
2257 /// Requested page size. The maximum page size is 100; this is also the default.
2258 ///
2259 /// Sets the *page size* query property to the given value.
2260 pub fn page_size(mut self, new_value: i32) -> BillingAccountSubAccountListCall<'a, C> {
2261 self._page_size = Some(new_value);
2262 self
2263 }
2264 /// Options for how to filter the returned billing accounts. This only supports filtering for [subaccounts](https://cloud.google.com/billing/docs/concepts) under a single provided parent billing account. (for example, `master_billing_account=billingAccounts/012345-678901-ABCDEF`). Boolean algebra and other fields are not currently supported.
2265 ///
2266 /// Sets the *filter* query property to the given value.
2267 pub fn filter(mut self, new_value: &str) -> BillingAccountSubAccountListCall<'a, C> {
2268 self._filter = Some(new_value.to_string());
2269 self
2270 }
2271 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2272 /// while executing the actual API request.
2273 ///
2274 /// ````text
2275 /// It should be used to handle progress information, and to implement a certain level of resilience.
2276 /// ````
2277 ///
2278 /// Sets the *delegate* property to the given value.
2279 pub fn delegate(
2280 mut self,
2281 new_value: &'a mut dyn common::Delegate,
2282 ) -> BillingAccountSubAccountListCall<'a, C> {
2283 self._delegate = Some(new_value);
2284 self
2285 }
2286
2287 /// Set any additional parameter of the query string used in the request.
2288 /// It should be used to set parameters which are not yet available through their own
2289 /// setters.
2290 ///
2291 /// Please note that this method must not be used to set any of the known parameters
2292 /// which have their own setter method. If done anyway, the request will fail.
2293 ///
2294 /// # Additional Parameters
2295 ///
2296 /// * *$.xgafv* (query-string) - V1 error format.
2297 /// * *access_token* (query-string) - OAuth access token.
2298 /// * *alt* (query-string) - Data format for response.
2299 /// * *callback* (query-string) - JSONP
2300 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2301 /// * *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.
2302 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2303 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2304 /// * *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.
2305 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2306 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2307 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountSubAccountListCall<'a, C>
2308 where
2309 T: AsRef<str>,
2310 {
2311 self._additional_params
2312 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2313 self
2314 }
2315
2316 /// Identifies the authorization scope for the method you are building.
2317 ///
2318 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2319 /// [`Scope::CloudBillingReadonly`].
2320 ///
2321 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2322 /// tokens for more than one scope.
2323 ///
2324 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2325 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2326 /// sufficient, a read-write scope will do as well.
2327 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountSubAccountListCall<'a, C>
2328 where
2329 St: AsRef<str>,
2330 {
2331 self._scopes.insert(String::from(scope.as_ref()));
2332 self
2333 }
2334 /// Identifies the authorization scope(s) for the method you are building.
2335 ///
2336 /// See [`Self::add_scope()`] for details.
2337 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountSubAccountListCall<'a, C>
2338 where
2339 I: IntoIterator<Item = St>,
2340 St: AsRef<str>,
2341 {
2342 self._scopes
2343 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2344 self
2345 }
2346
2347 /// Removes all scopes, and no default scope will be used either.
2348 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2349 /// for details).
2350 pub fn clear_scopes(mut self) -> BillingAccountSubAccountListCall<'a, C> {
2351 self._scopes.clear();
2352 self
2353 }
2354}
2355
2356/// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
2357///
2358/// A builder for the *create* method supported by a *billingAccount* resource.
2359/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2360///
2361/// # Example
2362///
2363/// Instantiate a resource method builder
2364///
2365/// ```test_harness,no_run
2366/// # extern crate hyper;
2367/// # extern crate hyper_rustls;
2368/// # extern crate google_cloudbilling1 as cloudbilling1;
2369/// use cloudbilling1::api::BillingAccount;
2370/// # async fn dox() {
2371/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2372///
2373/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2374/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2375/// # .with_native_roots()
2376/// # .unwrap()
2377/// # .https_only()
2378/// # .enable_http2()
2379/// # .build();
2380///
2381/// # let executor = hyper_util::rt::TokioExecutor::new();
2382/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2383/// # secret,
2384/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2385/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2386/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2387/// # ),
2388/// # ).build().await.unwrap();
2389///
2390/// # let client = hyper_util::client::legacy::Client::builder(
2391/// # hyper_util::rt::TokioExecutor::new()
2392/// # )
2393/// # .build(
2394/// # hyper_rustls::HttpsConnectorBuilder::new()
2395/// # .with_native_roots()
2396/// # .unwrap()
2397/// # .https_or_http()
2398/// # .enable_http2()
2399/// # .build()
2400/// # );
2401/// # let mut hub = Cloudbilling::new(client, auth);
2402/// // As the method needs a request, you would usually fill it with the desired information
2403/// // into the respective structure. Some of the parts shown here might not be applicable !
2404/// // Values shown here are possibly random and not representative !
2405/// let mut req = BillingAccount::default();
2406///
2407/// // You can configure optional parameters by calling the respective setters at will, and
2408/// // execute the final call using `doit()`.
2409/// // Values shown here are possibly random and not representative !
2410/// let result = hub.billing_accounts().create(req)
2411/// .parent("invidunt")
2412/// .doit().await;
2413/// # }
2414/// ```
2415pub struct BillingAccountCreateCall<'a, C>
2416where
2417 C: 'a,
2418{
2419 hub: &'a Cloudbilling<C>,
2420 _request: BillingAccount,
2421 _parent: Option<String>,
2422 _delegate: Option<&'a mut dyn common::Delegate>,
2423 _additional_params: HashMap<String, String>,
2424 _scopes: BTreeSet<String>,
2425}
2426
2427impl<'a, C> common::CallBuilder for BillingAccountCreateCall<'a, C> {}
2428
2429impl<'a, C> BillingAccountCreateCall<'a, C>
2430where
2431 C: common::Connector,
2432{
2433 /// Perform the operation you have build so far.
2434 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
2435 use std::borrow::Cow;
2436 use std::io::{Read, Seek};
2437
2438 use common::{url::Params, ToParts};
2439 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2440
2441 let mut dd = common::DefaultDelegate;
2442 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2443 dlg.begin(common::MethodInfo {
2444 id: "cloudbilling.billingAccounts.create",
2445 http_method: hyper::Method::POST,
2446 });
2447
2448 for &field in ["alt", "parent"].iter() {
2449 if self._additional_params.contains_key(field) {
2450 dlg.finished(false);
2451 return Err(common::Error::FieldClash(field));
2452 }
2453 }
2454
2455 let mut params = Params::with_capacity(4 + self._additional_params.len());
2456 if let Some(value) = self._parent.as_ref() {
2457 params.push("parent", value);
2458 }
2459
2460 params.extend(self._additional_params.iter());
2461
2462 params.push("alt", "json");
2463 let mut url = self.hub._base_url.clone() + "v1/billingAccounts";
2464 if self._scopes.is_empty() {
2465 self._scopes
2466 .insert(Scope::CloudPlatform.as_ref().to_string());
2467 }
2468
2469 let url = params.parse_with_url(&url);
2470
2471 let mut json_mime_type = mime::APPLICATION_JSON;
2472 let mut request_value_reader = {
2473 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2474 common::remove_json_null_values(&mut value);
2475 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2476 serde_json::to_writer(&mut dst, &value).unwrap();
2477 dst
2478 };
2479 let request_size = request_value_reader
2480 .seek(std::io::SeekFrom::End(0))
2481 .unwrap();
2482 request_value_reader
2483 .seek(std::io::SeekFrom::Start(0))
2484 .unwrap();
2485
2486 loop {
2487 let token = match self
2488 .hub
2489 .auth
2490 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2491 .await
2492 {
2493 Ok(token) => token,
2494 Err(e) => match dlg.token(e) {
2495 Ok(token) => token,
2496 Err(e) => {
2497 dlg.finished(false);
2498 return Err(common::Error::MissingToken(e));
2499 }
2500 },
2501 };
2502 request_value_reader
2503 .seek(std::io::SeekFrom::Start(0))
2504 .unwrap();
2505 let mut req_result = {
2506 let client = &self.hub.client;
2507 dlg.pre_request();
2508 let mut req_builder = hyper::Request::builder()
2509 .method(hyper::Method::POST)
2510 .uri(url.as_str())
2511 .header(USER_AGENT, self.hub._user_agent.clone());
2512
2513 if let Some(token) = token.as_ref() {
2514 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2515 }
2516
2517 let request = req_builder
2518 .header(CONTENT_TYPE, json_mime_type.to_string())
2519 .header(CONTENT_LENGTH, request_size as u64)
2520 .body(common::to_body(
2521 request_value_reader.get_ref().clone().into(),
2522 ));
2523
2524 client.request(request.unwrap()).await
2525 };
2526
2527 match req_result {
2528 Err(err) => {
2529 if let common::Retry::After(d) = dlg.http_error(&err) {
2530 sleep(d).await;
2531 continue;
2532 }
2533 dlg.finished(false);
2534 return Err(common::Error::HttpError(err));
2535 }
2536 Ok(res) => {
2537 let (mut parts, body) = res.into_parts();
2538 let mut body = common::Body::new(body);
2539 if !parts.status.is_success() {
2540 let bytes = common::to_bytes(body).await.unwrap_or_default();
2541 let error = serde_json::from_str(&common::to_string(&bytes));
2542 let response = common::to_response(parts, bytes.into());
2543
2544 if let common::Retry::After(d) =
2545 dlg.http_failure(&response, error.as_ref().ok())
2546 {
2547 sleep(d).await;
2548 continue;
2549 }
2550
2551 dlg.finished(false);
2552
2553 return Err(match error {
2554 Ok(value) => common::Error::BadRequest(value),
2555 _ => common::Error::Failure(response),
2556 });
2557 }
2558 let response = {
2559 let bytes = common::to_bytes(body).await.unwrap_or_default();
2560 let encoded = common::to_string(&bytes);
2561 match serde_json::from_str(&encoded) {
2562 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2563 Err(error) => {
2564 dlg.response_json_decode_error(&encoded, &error);
2565 return Err(common::Error::JsonDecodeError(
2566 encoded.to_string(),
2567 error,
2568 ));
2569 }
2570 }
2571 };
2572
2573 dlg.finished(true);
2574 return Ok(response);
2575 }
2576 }
2577 }
2578 }
2579
2580 ///
2581 /// Sets the *request* property to the given value.
2582 ///
2583 /// Even though the property as already been set when instantiating this call,
2584 /// we provide this method for API completeness.
2585 pub fn request(mut self, new_value: BillingAccount) -> BillingAccountCreateCall<'a, C> {
2586 self._request = new_value;
2587 self
2588 }
2589 /// Optional. The parent to create a billing account from. Format: - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
2590 ///
2591 /// Sets the *parent* query property to the given value.
2592 pub fn parent(mut self, new_value: &str) -> BillingAccountCreateCall<'a, C> {
2593 self._parent = Some(new_value.to_string());
2594 self
2595 }
2596 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2597 /// while executing the actual API request.
2598 ///
2599 /// ````text
2600 /// It should be used to handle progress information, and to implement a certain level of resilience.
2601 /// ````
2602 ///
2603 /// Sets the *delegate* property to the given value.
2604 pub fn delegate(
2605 mut self,
2606 new_value: &'a mut dyn common::Delegate,
2607 ) -> BillingAccountCreateCall<'a, C> {
2608 self._delegate = Some(new_value);
2609 self
2610 }
2611
2612 /// Set any additional parameter of the query string used in the request.
2613 /// It should be used to set parameters which are not yet available through their own
2614 /// setters.
2615 ///
2616 /// Please note that this method must not be used to set any of the known parameters
2617 /// which have their own setter method. If done anyway, the request will fail.
2618 ///
2619 /// # Additional Parameters
2620 ///
2621 /// * *$.xgafv* (query-string) - V1 error format.
2622 /// * *access_token* (query-string) - OAuth access token.
2623 /// * *alt* (query-string) - Data format for response.
2624 /// * *callback* (query-string) - JSONP
2625 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2626 /// * *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.
2627 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2628 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2629 /// * *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.
2630 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2631 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2632 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountCreateCall<'a, C>
2633 where
2634 T: AsRef<str>,
2635 {
2636 self._additional_params
2637 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2638 self
2639 }
2640
2641 /// Identifies the authorization scope for the method you are building.
2642 ///
2643 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2644 /// [`Scope::CloudPlatform`].
2645 ///
2646 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2647 /// tokens for more than one scope.
2648 ///
2649 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2650 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2651 /// sufficient, a read-write scope will do as well.
2652 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountCreateCall<'a, C>
2653 where
2654 St: AsRef<str>,
2655 {
2656 self._scopes.insert(String::from(scope.as_ref()));
2657 self
2658 }
2659 /// Identifies the authorization scope(s) for the method you are building.
2660 ///
2661 /// See [`Self::add_scope()`] for details.
2662 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountCreateCall<'a, C>
2663 where
2664 I: IntoIterator<Item = St>,
2665 St: AsRef<str>,
2666 {
2667 self._scopes
2668 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2669 self
2670 }
2671
2672 /// Removes all scopes, and no default scope will be used either.
2673 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2674 /// for details).
2675 pub fn clear_scopes(mut self) -> BillingAccountCreateCall<'a, C> {
2676 self._scopes.clear();
2677 self
2678 }
2679}
2680
2681/// Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](https://cloud.google.com/billing/docs/how-to/billing-access).
2682///
2683/// A builder for the *get* method supported by a *billingAccount* resource.
2684/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2685///
2686/// # Example
2687///
2688/// Instantiate a resource method builder
2689///
2690/// ```test_harness,no_run
2691/// # extern crate hyper;
2692/// # extern crate hyper_rustls;
2693/// # extern crate google_cloudbilling1 as cloudbilling1;
2694/// # async fn dox() {
2695/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2696///
2697/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2698/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2699/// # .with_native_roots()
2700/// # .unwrap()
2701/// # .https_only()
2702/// # .enable_http2()
2703/// # .build();
2704///
2705/// # let executor = hyper_util::rt::TokioExecutor::new();
2706/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2707/// # secret,
2708/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2709/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2710/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2711/// # ),
2712/// # ).build().await.unwrap();
2713///
2714/// # let client = hyper_util::client::legacy::Client::builder(
2715/// # hyper_util::rt::TokioExecutor::new()
2716/// # )
2717/// # .build(
2718/// # hyper_rustls::HttpsConnectorBuilder::new()
2719/// # .with_native_roots()
2720/// # .unwrap()
2721/// # .https_or_http()
2722/// # .enable_http2()
2723/// # .build()
2724/// # );
2725/// # let mut hub = Cloudbilling::new(client, auth);
2726/// // You can configure optional parameters by calling the respective setters at will, and
2727/// // execute the final call using `doit()`.
2728/// // Values shown here are possibly random and not representative !
2729/// let result = hub.billing_accounts().get("name")
2730/// .doit().await;
2731/// # }
2732/// ```
2733pub struct BillingAccountGetCall<'a, C>
2734where
2735 C: 'a,
2736{
2737 hub: &'a Cloudbilling<C>,
2738 _name: String,
2739 _delegate: Option<&'a mut dyn common::Delegate>,
2740 _additional_params: HashMap<String, String>,
2741 _scopes: BTreeSet<String>,
2742}
2743
2744impl<'a, C> common::CallBuilder for BillingAccountGetCall<'a, C> {}
2745
2746impl<'a, C> BillingAccountGetCall<'a, C>
2747where
2748 C: common::Connector,
2749{
2750 /// Perform the operation you have build so far.
2751 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
2752 use std::borrow::Cow;
2753 use std::io::{Read, Seek};
2754
2755 use common::{url::Params, ToParts};
2756 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2757
2758 let mut dd = common::DefaultDelegate;
2759 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2760 dlg.begin(common::MethodInfo {
2761 id: "cloudbilling.billingAccounts.get",
2762 http_method: hyper::Method::GET,
2763 });
2764
2765 for &field in ["alt", "name"].iter() {
2766 if self._additional_params.contains_key(field) {
2767 dlg.finished(false);
2768 return Err(common::Error::FieldClash(field));
2769 }
2770 }
2771
2772 let mut params = Params::with_capacity(3 + self._additional_params.len());
2773 params.push("name", self._name);
2774
2775 params.extend(self._additional_params.iter());
2776
2777 params.push("alt", "json");
2778 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2779 if self._scopes.is_empty() {
2780 self._scopes
2781 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
2782 }
2783
2784 #[allow(clippy::single_element_loop)]
2785 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2786 url = params.uri_replacement(url, param_name, find_this, true);
2787 }
2788 {
2789 let to_remove = ["name"];
2790 params.remove_params(&to_remove);
2791 }
2792
2793 let url = params.parse_with_url(&url);
2794
2795 loop {
2796 let token = match self
2797 .hub
2798 .auth
2799 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2800 .await
2801 {
2802 Ok(token) => token,
2803 Err(e) => match dlg.token(e) {
2804 Ok(token) => token,
2805 Err(e) => {
2806 dlg.finished(false);
2807 return Err(common::Error::MissingToken(e));
2808 }
2809 },
2810 };
2811 let mut req_result = {
2812 let client = &self.hub.client;
2813 dlg.pre_request();
2814 let mut req_builder = hyper::Request::builder()
2815 .method(hyper::Method::GET)
2816 .uri(url.as_str())
2817 .header(USER_AGENT, self.hub._user_agent.clone());
2818
2819 if let Some(token) = token.as_ref() {
2820 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2821 }
2822
2823 let request = req_builder
2824 .header(CONTENT_LENGTH, 0_u64)
2825 .body(common::to_body::<String>(None));
2826
2827 client.request(request.unwrap()).await
2828 };
2829
2830 match req_result {
2831 Err(err) => {
2832 if let common::Retry::After(d) = dlg.http_error(&err) {
2833 sleep(d).await;
2834 continue;
2835 }
2836 dlg.finished(false);
2837 return Err(common::Error::HttpError(err));
2838 }
2839 Ok(res) => {
2840 let (mut parts, body) = res.into_parts();
2841 let mut body = common::Body::new(body);
2842 if !parts.status.is_success() {
2843 let bytes = common::to_bytes(body).await.unwrap_or_default();
2844 let error = serde_json::from_str(&common::to_string(&bytes));
2845 let response = common::to_response(parts, bytes.into());
2846
2847 if let common::Retry::After(d) =
2848 dlg.http_failure(&response, error.as_ref().ok())
2849 {
2850 sleep(d).await;
2851 continue;
2852 }
2853
2854 dlg.finished(false);
2855
2856 return Err(match error {
2857 Ok(value) => common::Error::BadRequest(value),
2858 _ => common::Error::Failure(response),
2859 });
2860 }
2861 let response = {
2862 let bytes = common::to_bytes(body).await.unwrap_or_default();
2863 let encoded = common::to_string(&bytes);
2864 match serde_json::from_str(&encoded) {
2865 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2866 Err(error) => {
2867 dlg.response_json_decode_error(&encoded, &error);
2868 return Err(common::Error::JsonDecodeError(
2869 encoded.to_string(),
2870 error,
2871 ));
2872 }
2873 }
2874 };
2875
2876 dlg.finished(true);
2877 return Ok(response);
2878 }
2879 }
2880 }
2881 }
2882
2883 /// Required. The resource name of the billing account to retrieve. For example, `billingAccounts/012345-567890-ABCDEF`.
2884 ///
2885 /// Sets the *name* path property to the given value.
2886 ///
2887 /// Even though the property as already been set when instantiating this call,
2888 /// we provide this method for API completeness.
2889 pub fn name(mut self, new_value: &str) -> BillingAccountGetCall<'a, C> {
2890 self._name = new_value.to_string();
2891 self
2892 }
2893 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2894 /// while executing the actual API request.
2895 ///
2896 /// ````text
2897 /// It should be used to handle progress information, and to implement a certain level of resilience.
2898 /// ````
2899 ///
2900 /// Sets the *delegate* property to the given value.
2901 pub fn delegate(
2902 mut self,
2903 new_value: &'a mut dyn common::Delegate,
2904 ) -> BillingAccountGetCall<'a, C> {
2905 self._delegate = Some(new_value);
2906 self
2907 }
2908
2909 /// Set any additional parameter of the query string used in the request.
2910 /// It should be used to set parameters which are not yet available through their own
2911 /// setters.
2912 ///
2913 /// Please note that this method must not be used to set any of the known parameters
2914 /// which have their own setter method. If done anyway, the request will fail.
2915 ///
2916 /// # Additional Parameters
2917 ///
2918 /// * *$.xgafv* (query-string) - V1 error format.
2919 /// * *access_token* (query-string) - OAuth access token.
2920 /// * *alt* (query-string) - Data format for response.
2921 /// * *callback* (query-string) - JSONP
2922 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2923 /// * *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.
2924 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2925 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2926 /// * *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.
2927 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2928 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2929 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountGetCall<'a, C>
2930 where
2931 T: AsRef<str>,
2932 {
2933 self._additional_params
2934 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2935 self
2936 }
2937
2938 /// Identifies the authorization scope for the method you are building.
2939 ///
2940 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2941 /// [`Scope::CloudBillingReadonly`].
2942 ///
2943 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2944 /// tokens for more than one scope.
2945 ///
2946 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2947 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2948 /// sufficient, a read-write scope will do as well.
2949 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountGetCall<'a, C>
2950 where
2951 St: AsRef<str>,
2952 {
2953 self._scopes.insert(String::from(scope.as_ref()));
2954 self
2955 }
2956 /// Identifies the authorization scope(s) for the method you are building.
2957 ///
2958 /// See [`Self::add_scope()`] for details.
2959 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountGetCall<'a, C>
2960 where
2961 I: IntoIterator<Item = St>,
2962 St: AsRef<str>,
2963 {
2964 self._scopes
2965 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2966 self
2967 }
2968
2969 /// Removes all scopes, and no default scope will be used either.
2970 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2971 /// for details).
2972 pub fn clear_scopes(mut self) -> BillingAccountGetCall<'a, C> {
2973 self._scopes.clear();
2974 self
2975 }
2976}
2977
2978/// Gets the access control policy for a billing account. The caller must have the `billing.accounts.getIamPolicy` permission on the account, which is often given to billing account [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
2979///
2980/// A builder for the *getIamPolicy* method supported by a *billingAccount* resource.
2981/// It is not used directly, but through a [`BillingAccountMethods`] instance.
2982///
2983/// # Example
2984///
2985/// Instantiate a resource method builder
2986///
2987/// ```test_harness,no_run
2988/// # extern crate hyper;
2989/// # extern crate hyper_rustls;
2990/// # extern crate google_cloudbilling1 as cloudbilling1;
2991/// # async fn dox() {
2992/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2993///
2994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2995/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2996/// # .with_native_roots()
2997/// # .unwrap()
2998/// # .https_only()
2999/// # .enable_http2()
3000/// # .build();
3001///
3002/// # let executor = hyper_util::rt::TokioExecutor::new();
3003/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3004/// # secret,
3005/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3006/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3007/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3008/// # ),
3009/// # ).build().await.unwrap();
3010///
3011/// # let client = hyper_util::client::legacy::Client::builder(
3012/// # hyper_util::rt::TokioExecutor::new()
3013/// # )
3014/// # .build(
3015/// # hyper_rustls::HttpsConnectorBuilder::new()
3016/// # .with_native_roots()
3017/// # .unwrap()
3018/// # .https_or_http()
3019/// # .enable_http2()
3020/// # .build()
3021/// # );
3022/// # let mut hub = Cloudbilling::new(client, auth);
3023/// // You can configure optional parameters by calling the respective setters at will, and
3024/// // execute the final call using `doit()`.
3025/// // Values shown here are possibly random and not representative !
3026/// let result = hub.billing_accounts().get_iam_policy("resource")
3027/// .options_requested_policy_version(-50)
3028/// .doit().await;
3029/// # }
3030/// ```
3031pub struct BillingAccountGetIamPolicyCall<'a, C>
3032where
3033 C: 'a,
3034{
3035 hub: &'a Cloudbilling<C>,
3036 _resource: String,
3037 _options_requested_policy_version: Option<i32>,
3038 _delegate: Option<&'a mut dyn common::Delegate>,
3039 _additional_params: HashMap<String, String>,
3040 _scopes: BTreeSet<String>,
3041}
3042
3043impl<'a, C> common::CallBuilder for BillingAccountGetIamPolicyCall<'a, C> {}
3044
3045impl<'a, C> BillingAccountGetIamPolicyCall<'a, C>
3046where
3047 C: common::Connector,
3048{
3049 /// Perform the operation you have build so far.
3050 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
3051 use std::borrow::Cow;
3052 use std::io::{Read, Seek};
3053
3054 use common::{url::Params, ToParts};
3055 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3056
3057 let mut dd = common::DefaultDelegate;
3058 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3059 dlg.begin(common::MethodInfo {
3060 id: "cloudbilling.billingAccounts.getIamPolicy",
3061 http_method: hyper::Method::GET,
3062 });
3063
3064 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
3065 if self._additional_params.contains_key(field) {
3066 dlg.finished(false);
3067 return Err(common::Error::FieldClash(field));
3068 }
3069 }
3070
3071 let mut params = Params::with_capacity(4 + self._additional_params.len());
3072 params.push("resource", self._resource);
3073 if let Some(value) = self._options_requested_policy_version.as_ref() {
3074 params.push("options.requestedPolicyVersion", value.to_string());
3075 }
3076
3077 params.extend(self._additional_params.iter());
3078
3079 params.push("alt", "json");
3080 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
3081 if self._scopes.is_empty() {
3082 self._scopes
3083 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
3084 }
3085
3086 #[allow(clippy::single_element_loop)]
3087 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3088 url = params.uri_replacement(url, param_name, find_this, true);
3089 }
3090 {
3091 let to_remove = ["resource"];
3092 params.remove_params(&to_remove);
3093 }
3094
3095 let url = params.parse_with_url(&url);
3096
3097 loop {
3098 let token = match self
3099 .hub
3100 .auth
3101 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3102 .await
3103 {
3104 Ok(token) => token,
3105 Err(e) => match dlg.token(e) {
3106 Ok(token) => token,
3107 Err(e) => {
3108 dlg.finished(false);
3109 return Err(common::Error::MissingToken(e));
3110 }
3111 },
3112 };
3113 let mut req_result = {
3114 let client = &self.hub.client;
3115 dlg.pre_request();
3116 let mut req_builder = hyper::Request::builder()
3117 .method(hyper::Method::GET)
3118 .uri(url.as_str())
3119 .header(USER_AGENT, self.hub._user_agent.clone());
3120
3121 if let Some(token) = token.as_ref() {
3122 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3123 }
3124
3125 let request = req_builder
3126 .header(CONTENT_LENGTH, 0_u64)
3127 .body(common::to_body::<String>(None));
3128
3129 client.request(request.unwrap()).await
3130 };
3131
3132 match req_result {
3133 Err(err) => {
3134 if let common::Retry::After(d) = dlg.http_error(&err) {
3135 sleep(d).await;
3136 continue;
3137 }
3138 dlg.finished(false);
3139 return Err(common::Error::HttpError(err));
3140 }
3141 Ok(res) => {
3142 let (mut parts, body) = res.into_parts();
3143 let mut body = common::Body::new(body);
3144 if !parts.status.is_success() {
3145 let bytes = common::to_bytes(body).await.unwrap_or_default();
3146 let error = serde_json::from_str(&common::to_string(&bytes));
3147 let response = common::to_response(parts, bytes.into());
3148
3149 if let common::Retry::After(d) =
3150 dlg.http_failure(&response, error.as_ref().ok())
3151 {
3152 sleep(d).await;
3153 continue;
3154 }
3155
3156 dlg.finished(false);
3157
3158 return Err(match error {
3159 Ok(value) => common::Error::BadRequest(value),
3160 _ => common::Error::Failure(response),
3161 });
3162 }
3163 let response = {
3164 let bytes = common::to_bytes(body).await.unwrap_or_default();
3165 let encoded = common::to_string(&bytes);
3166 match serde_json::from_str(&encoded) {
3167 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3168 Err(error) => {
3169 dlg.response_json_decode_error(&encoded, &error);
3170 return Err(common::Error::JsonDecodeError(
3171 encoded.to_string(),
3172 error,
3173 ));
3174 }
3175 }
3176 };
3177
3178 dlg.finished(true);
3179 return Ok(response);
3180 }
3181 }
3182 }
3183 }
3184
3185 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3186 ///
3187 /// Sets the *resource* path property to the given value.
3188 ///
3189 /// Even though the property as already been set when instantiating this call,
3190 /// we provide this method for API completeness.
3191 pub fn resource(mut self, new_value: &str) -> BillingAccountGetIamPolicyCall<'a, C> {
3192 self._resource = new_value.to_string();
3193 self
3194 }
3195 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
3196 ///
3197 /// Sets the *options.requested policy version* query property to the given value.
3198 pub fn options_requested_policy_version(
3199 mut self,
3200 new_value: i32,
3201 ) -> BillingAccountGetIamPolicyCall<'a, C> {
3202 self._options_requested_policy_version = Some(new_value);
3203 self
3204 }
3205 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3206 /// while executing the actual API request.
3207 ///
3208 /// ````text
3209 /// It should be used to handle progress information, and to implement a certain level of resilience.
3210 /// ````
3211 ///
3212 /// Sets the *delegate* property to the given value.
3213 pub fn delegate(
3214 mut self,
3215 new_value: &'a mut dyn common::Delegate,
3216 ) -> BillingAccountGetIamPolicyCall<'a, C> {
3217 self._delegate = Some(new_value);
3218 self
3219 }
3220
3221 /// Set any additional parameter of the query string used in the request.
3222 /// It should be used to set parameters which are not yet available through their own
3223 /// setters.
3224 ///
3225 /// Please note that this method must not be used to set any of the known parameters
3226 /// which have their own setter method. If done anyway, the request will fail.
3227 ///
3228 /// # Additional Parameters
3229 ///
3230 /// * *$.xgafv* (query-string) - V1 error format.
3231 /// * *access_token* (query-string) - OAuth access token.
3232 /// * *alt* (query-string) - Data format for response.
3233 /// * *callback* (query-string) - JSONP
3234 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3235 /// * *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.
3236 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3237 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3238 /// * *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.
3239 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3240 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3241 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountGetIamPolicyCall<'a, C>
3242 where
3243 T: AsRef<str>,
3244 {
3245 self._additional_params
3246 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3247 self
3248 }
3249
3250 /// Identifies the authorization scope for the method you are building.
3251 ///
3252 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3253 /// [`Scope::CloudBillingReadonly`].
3254 ///
3255 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3256 /// tokens for more than one scope.
3257 ///
3258 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3259 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3260 /// sufficient, a read-write scope will do as well.
3261 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountGetIamPolicyCall<'a, C>
3262 where
3263 St: AsRef<str>,
3264 {
3265 self._scopes.insert(String::from(scope.as_ref()));
3266 self
3267 }
3268 /// Identifies the authorization scope(s) for the method you are building.
3269 ///
3270 /// See [`Self::add_scope()`] for details.
3271 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountGetIamPolicyCall<'a, C>
3272 where
3273 I: IntoIterator<Item = St>,
3274 St: AsRef<str>,
3275 {
3276 self._scopes
3277 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3278 self
3279 }
3280
3281 /// Removes all scopes, and no default scope will be used either.
3282 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3283 /// for details).
3284 pub fn clear_scopes(mut self) -> BillingAccountGetIamPolicyCall<'a, C> {
3285 self._scopes.clear();
3286 self
3287 }
3288}
3289
3290/// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
3291///
3292/// A builder for the *list* method supported by a *billingAccount* resource.
3293/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3294///
3295/// # Example
3296///
3297/// Instantiate a resource method builder
3298///
3299/// ```test_harness,no_run
3300/// # extern crate hyper;
3301/// # extern crate hyper_rustls;
3302/// # extern crate google_cloudbilling1 as cloudbilling1;
3303/// # async fn dox() {
3304/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3305///
3306/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3307/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3308/// # .with_native_roots()
3309/// # .unwrap()
3310/// # .https_only()
3311/// # .enable_http2()
3312/// # .build();
3313///
3314/// # let executor = hyper_util::rt::TokioExecutor::new();
3315/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3316/// # secret,
3317/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3318/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3319/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3320/// # ),
3321/// # ).build().await.unwrap();
3322///
3323/// # let client = hyper_util::client::legacy::Client::builder(
3324/// # hyper_util::rt::TokioExecutor::new()
3325/// # )
3326/// # .build(
3327/// # hyper_rustls::HttpsConnectorBuilder::new()
3328/// # .with_native_roots()
3329/// # .unwrap()
3330/// # .https_or_http()
3331/// # .enable_http2()
3332/// # .build()
3333/// # );
3334/// # let mut hub = Cloudbilling::new(client, auth);
3335/// // You can configure optional parameters by calling the respective setters at will, and
3336/// // execute the final call using `doit()`.
3337/// // Values shown here are possibly random and not representative !
3338/// let result = hub.billing_accounts().list()
3339/// .parent("sed")
3340/// .page_token("ut")
3341/// .page_size(-12)
3342/// .filter("rebum.")
3343/// .doit().await;
3344/// # }
3345/// ```
3346pub struct BillingAccountListCall<'a, C>
3347where
3348 C: 'a,
3349{
3350 hub: &'a Cloudbilling<C>,
3351 _parent: Option<String>,
3352 _page_token: Option<String>,
3353 _page_size: Option<i32>,
3354 _filter: Option<String>,
3355 _delegate: Option<&'a mut dyn common::Delegate>,
3356 _additional_params: HashMap<String, String>,
3357 _scopes: BTreeSet<String>,
3358}
3359
3360impl<'a, C> common::CallBuilder for BillingAccountListCall<'a, C> {}
3361
3362impl<'a, C> BillingAccountListCall<'a, C>
3363where
3364 C: common::Connector,
3365{
3366 /// Perform the operation you have build so far.
3367 pub async fn doit(mut self) -> common::Result<(common::Response, ListBillingAccountsResponse)> {
3368 use std::borrow::Cow;
3369 use std::io::{Read, Seek};
3370
3371 use common::{url::Params, ToParts};
3372 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3373
3374 let mut dd = common::DefaultDelegate;
3375 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3376 dlg.begin(common::MethodInfo {
3377 id: "cloudbilling.billingAccounts.list",
3378 http_method: hyper::Method::GET,
3379 });
3380
3381 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
3382 if self._additional_params.contains_key(field) {
3383 dlg.finished(false);
3384 return Err(common::Error::FieldClash(field));
3385 }
3386 }
3387
3388 let mut params = Params::with_capacity(6 + self._additional_params.len());
3389 if let Some(value) = self._parent.as_ref() {
3390 params.push("parent", value);
3391 }
3392 if let Some(value) = self._page_token.as_ref() {
3393 params.push("pageToken", value);
3394 }
3395 if let Some(value) = self._page_size.as_ref() {
3396 params.push("pageSize", value.to_string());
3397 }
3398 if let Some(value) = self._filter.as_ref() {
3399 params.push("filter", value);
3400 }
3401
3402 params.extend(self._additional_params.iter());
3403
3404 params.push("alt", "json");
3405 let mut url = self.hub._base_url.clone() + "v1/billingAccounts";
3406 if self._scopes.is_empty() {
3407 self._scopes
3408 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
3409 }
3410
3411 let url = params.parse_with_url(&url);
3412
3413 loop {
3414 let token = match self
3415 .hub
3416 .auth
3417 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3418 .await
3419 {
3420 Ok(token) => token,
3421 Err(e) => match dlg.token(e) {
3422 Ok(token) => token,
3423 Err(e) => {
3424 dlg.finished(false);
3425 return Err(common::Error::MissingToken(e));
3426 }
3427 },
3428 };
3429 let mut req_result = {
3430 let client = &self.hub.client;
3431 dlg.pre_request();
3432 let mut req_builder = hyper::Request::builder()
3433 .method(hyper::Method::GET)
3434 .uri(url.as_str())
3435 .header(USER_AGENT, self.hub._user_agent.clone());
3436
3437 if let Some(token) = token.as_ref() {
3438 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3439 }
3440
3441 let request = req_builder
3442 .header(CONTENT_LENGTH, 0_u64)
3443 .body(common::to_body::<String>(None));
3444
3445 client.request(request.unwrap()).await
3446 };
3447
3448 match req_result {
3449 Err(err) => {
3450 if let common::Retry::After(d) = dlg.http_error(&err) {
3451 sleep(d).await;
3452 continue;
3453 }
3454 dlg.finished(false);
3455 return Err(common::Error::HttpError(err));
3456 }
3457 Ok(res) => {
3458 let (mut parts, body) = res.into_parts();
3459 let mut body = common::Body::new(body);
3460 if !parts.status.is_success() {
3461 let bytes = common::to_bytes(body).await.unwrap_or_default();
3462 let error = serde_json::from_str(&common::to_string(&bytes));
3463 let response = common::to_response(parts, bytes.into());
3464
3465 if let common::Retry::After(d) =
3466 dlg.http_failure(&response, error.as_ref().ok())
3467 {
3468 sleep(d).await;
3469 continue;
3470 }
3471
3472 dlg.finished(false);
3473
3474 return Err(match error {
3475 Ok(value) => common::Error::BadRequest(value),
3476 _ => common::Error::Failure(response),
3477 });
3478 }
3479 let response = {
3480 let bytes = common::to_bytes(body).await.unwrap_or_default();
3481 let encoded = common::to_string(&bytes);
3482 match serde_json::from_str(&encoded) {
3483 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3484 Err(error) => {
3485 dlg.response_json_decode_error(&encoded, &error);
3486 return Err(common::Error::JsonDecodeError(
3487 encoded.to_string(),
3488 error,
3489 ));
3490 }
3491 }
3492 };
3493
3494 dlg.finished(true);
3495 return Ok(response);
3496 }
3497 }
3498 }
3499 }
3500
3501 /// Optional. The parent resource to list billing accounts from. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
3502 ///
3503 /// Sets the *parent* query property to the given value.
3504 pub fn parent(mut self, new_value: &str) -> BillingAccountListCall<'a, C> {
3505 self._parent = Some(new_value.to_string());
3506 self
3507 }
3508 /// A token identifying a page of results to return. This should be a `next_page_token` value returned from a previous `ListBillingAccounts` call. If unspecified, the first page of results is returned.
3509 ///
3510 /// Sets the *page token* query property to the given value.
3511 pub fn page_token(mut self, new_value: &str) -> BillingAccountListCall<'a, C> {
3512 self._page_token = Some(new_value.to_string());
3513 self
3514 }
3515 /// Requested page size. The maximum page size is 100; this is also the default.
3516 ///
3517 /// Sets the *page size* query property to the given value.
3518 pub fn page_size(mut self, new_value: i32) -> BillingAccountListCall<'a, C> {
3519 self._page_size = Some(new_value);
3520 self
3521 }
3522 /// Options for how to filter the returned billing accounts. This only supports filtering for [subaccounts](https://cloud.google.com/billing/docs/concepts) under a single provided parent billing account. (for example, `master_billing_account=billingAccounts/012345-678901-ABCDEF`). Boolean algebra and other fields are not currently supported.
3523 ///
3524 /// Sets the *filter* query property to the given value.
3525 pub fn filter(mut self, new_value: &str) -> BillingAccountListCall<'a, C> {
3526 self._filter = Some(new_value.to_string());
3527 self
3528 }
3529 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3530 /// while executing the actual API request.
3531 ///
3532 /// ````text
3533 /// It should be used to handle progress information, and to implement a certain level of resilience.
3534 /// ````
3535 ///
3536 /// Sets the *delegate* property to the given value.
3537 pub fn delegate(
3538 mut self,
3539 new_value: &'a mut dyn common::Delegate,
3540 ) -> BillingAccountListCall<'a, C> {
3541 self._delegate = Some(new_value);
3542 self
3543 }
3544
3545 /// Set any additional parameter of the query string used in the request.
3546 /// It should be used to set parameters which are not yet available through their own
3547 /// setters.
3548 ///
3549 /// Please note that this method must not be used to set any of the known parameters
3550 /// which have their own setter method. If done anyway, the request will fail.
3551 ///
3552 /// # Additional Parameters
3553 ///
3554 /// * *$.xgafv* (query-string) - V1 error format.
3555 /// * *access_token* (query-string) - OAuth access token.
3556 /// * *alt* (query-string) - Data format for response.
3557 /// * *callback* (query-string) - JSONP
3558 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3559 /// * *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.
3560 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3561 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3562 /// * *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.
3563 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3564 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3565 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountListCall<'a, C>
3566 where
3567 T: AsRef<str>,
3568 {
3569 self._additional_params
3570 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3571 self
3572 }
3573
3574 /// Identifies the authorization scope for the method you are building.
3575 ///
3576 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3577 /// [`Scope::CloudBillingReadonly`].
3578 ///
3579 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3580 /// tokens for more than one scope.
3581 ///
3582 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3583 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3584 /// sufficient, a read-write scope will do as well.
3585 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountListCall<'a, C>
3586 where
3587 St: AsRef<str>,
3588 {
3589 self._scopes.insert(String::from(scope.as_ref()));
3590 self
3591 }
3592 /// Identifies the authorization scope(s) for the method you are building.
3593 ///
3594 /// See [`Self::add_scope()`] for details.
3595 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountListCall<'a, C>
3596 where
3597 I: IntoIterator<Item = St>,
3598 St: AsRef<str>,
3599 {
3600 self._scopes
3601 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3602 self
3603 }
3604
3605 /// Removes all scopes, and no default scope will be used either.
3606 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3607 /// for details).
3608 pub fn clear_scopes(mut self) -> BillingAccountListCall<'a, C> {
3609 self._scopes.clear();
3610 self
3611 }
3612}
3613
3614/// Changes which parent organization a billing account belongs to.
3615///
3616/// A builder for the *move* method supported by a *billingAccount* resource.
3617/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3618///
3619/// # Example
3620///
3621/// Instantiate a resource method builder
3622///
3623/// ```test_harness,no_run
3624/// # extern crate hyper;
3625/// # extern crate hyper_rustls;
3626/// # extern crate google_cloudbilling1 as cloudbilling1;
3627/// use cloudbilling1::api::MoveBillingAccountRequest;
3628/// # async fn dox() {
3629/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3630///
3631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3633/// # .with_native_roots()
3634/// # .unwrap()
3635/// # .https_only()
3636/// # .enable_http2()
3637/// # .build();
3638///
3639/// # let executor = hyper_util::rt::TokioExecutor::new();
3640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3641/// # secret,
3642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3643/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3644/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3645/// # ),
3646/// # ).build().await.unwrap();
3647///
3648/// # let client = hyper_util::client::legacy::Client::builder(
3649/// # hyper_util::rt::TokioExecutor::new()
3650/// # )
3651/// # .build(
3652/// # hyper_rustls::HttpsConnectorBuilder::new()
3653/// # .with_native_roots()
3654/// # .unwrap()
3655/// # .https_or_http()
3656/// # .enable_http2()
3657/// # .build()
3658/// # );
3659/// # let mut hub = Cloudbilling::new(client, auth);
3660/// // As the method needs a request, you would usually fill it with the desired information
3661/// // into the respective structure. Some of the parts shown here might not be applicable !
3662/// // Values shown here are possibly random and not representative !
3663/// let mut req = MoveBillingAccountRequest::default();
3664///
3665/// // You can configure optional parameters by calling the respective setters at will, and
3666/// // execute the final call using `doit()`.
3667/// // Values shown here are possibly random and not representative !
3668/// let result = hub.billing_accounts().move_(req, "name")
3669/// .doit().await;
3670/// # }
3671/// ```
3672pub struct BillingAccountMoveCall<'a, C>
3673where
3674 C: 'a,
3675{
3676 hub: &'a Cloudbilling<C>,
3677 _request: MoveBillingAccountRequest,
3678 _name: String,
3679 _delegate: Option<&'a mut dyn common::Delegate>,
3680 _additional_params: HashMap<String, String>,
3681 _scopes: BTreeSet<String>,
3682}
3683
3684impl<'a, C> common::CallBuilder for BillingAccountMoveCall<'a, C> {}
3685
3686impl<'a, C> BillingAccountMoveCall<'a, C>
3687where
3688 C: common::Connector,
3689{
3690 /// Perform the operation you have build so far.
3691 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
3692 use std::borrow::Cow;
3693 use std::io::{Read, Seek};
3694
3695 use common::{url::Params, ToParts};
3696 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3697
3698 let mut dd = common::DefaultDelegate;
3699 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3700 dlg.begin(common::MethodInfo {
3701 id: "cloudbilling.billingAccounts.move",
3702 http_method: hyper::Method::POST,
3703 });
3704
3705 for &field in ["alt", "name"].iter() {
3706 if self._additional_params.contains_key(field) {
3707 dlg.finished(false);
3708 return Err(common::Error::FieldClash(field));
3709 }
3710 }
3711
3712 let mut params = Params::with_capacity(4 + self._additional_params.len());
3713 params.push("name", self._name);
3714
3715 params.extend(self._additional_params.iter());
3716
3717 params.push("alt", "json");
3718 let mut url = self.hub._base_url.clone() + "v1/{+name}:move";
3719 if self._scopes.is_empty() {
3720 self._scopes
3721 .insert(Scope::CloudPlatform.as_ref().to_string());
3722 }
3723
3724 #[allow(clippy::single_element_loop)]
3725 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3726 url = params.uri_replacement(url, param_name, find_this, true);
3727 }
3728 {
3729 let to_remove = ["name"];
3730 params.remove_params(&to_remove);
3731 }
3732
3733 let url = params.parse_with_url(&url);
3734
3735 let mut json_mime_type = mime::APPLICATION_JSON;
3736 let mut request_value_reader = {
3737 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3738 common::remove_json_null_values(&mut value);
3739 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3740 serde_json::to_writer(&mut dst, &value).unwrap();
3741 dst
3742 };
3743 let request_size = request_value_reader
3744 .seek(std::io::SeekFrom::End(0))
3745 .unwrap();
3746 request_value_reader
3747 .seek(std::io::SeekFrom::Start(0))
3748 .unwrap();
3749
3750 loop {
3751 let token = match self
3752 .hub
3753 .auth
3754 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3755 .await
3756 {
3757 Ok(token) => token,
3758 Err(e) => match dlg.token(e) {
3759 Ok(token) => token,
3760 Err(e) => {
3761 dlg.finished(false);
3762 return Err(common::Error::MissingToken(e));
3763 }
3764 },
3765 };
3766 request_value_reader
3767 .seek(std::io::SeekFrom::Start(0))
3768 .unwrap();
3769 let mut req_result = {
3770 let client = &self.hub.client;
3771 dlg.pre_request();
3772 let mut req_builder = hyper::Request::builder()
3773 .method(hyper::Method::POST)
3774 .uri(url.as_str())
3775 .header(USER_AGENT, self.hub._user_agent.clone());
3776
3777 if let Some(token) = token.as_ref() {
3778 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3779 }
3780
3781 let request = req_builder
3782 .header(CONTENT_TYPE, json_mime_type.to_string())
3783 .header(CONTENT_LENGTH, request_size as u64)
3784 .body(common::to_body(
3785 request_value_reader.get_ref().clone().into(),
3786 ));
3787
3788 client.request(request.unwrap()).await
3789 };
3790
3791 match req_result {
3792 Err(err) => {
3793 if let common::Retry::After(d) = dlg.http_error(&err) {
3794 sleep(d).await;
3795 continue;
3796 }
3797 dlg.finished(false);
3798 return Err(common::Error::HttpError(err));
3799 }
3800 Ok(res) => {
3801 let (mut parts, body) = res.into_parts();
3802 let mut body = common::Body::new(body);
3803 if !parts.status.is_success() {
3804 let bytes = common::to_bytes(body).await.unwrap_or_default();
3805 let error = serde_json::from_str(&common::to_string(&bytes));
3806 let response = common::to_response(parts, bytes.into());
3807
3808 if let common::Retry::After(d) =
3809 dlg.http_failure(&response, error.as_ref().ok())
3810 {
3811 sleep(d).await;
3812 continue;
3813 }
3814
3815 dlg.finished(false);
3816
3817 return Err(match error {
3818 Ok(value) => common::Error::BadRequest(value),
3819 _ => common::Error::Failure(response),
3820 });
3821 }
3822 let response = {
3823 let bytes = common::to_bytes(body).await.unwrap_or_default();
3824 let encoded = common::to_string(&bytes);
3825 match serde_json::from_str(&encoded) {
3826 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3827 Err(error) => {
3828 dlg.response_json_decode_error(&encoded, &error);
3829 return Err(common::Error::JsonDecodeError(
3830 encoded.to_string(),
3831 error,
3832 ));
3833 }
3834 }
3835 };
3836
3837 dlg.finished(true);
3838 return Ok(response);
3839 }
3840 }
3841 }
3842 }
3843
3844 ///
3845 /// Sets the *request* property to the given value.
3846 ///
3847 /// Even though the property as already been set when instantiating this call,
3848 /// we provide this method for API completeness.
3849 pub fn request(
3850 mut self,
3851 new_value: MoveBillingAccountRequest,
3852 ) -> BillingAccountMoveCall<'a, C> {
3853 self._request = new_value;
3854 self
3855 }
3856 /// Required. The resource name of the billing account to move. Must be of the form `billingAccounts/{billing_account_id}`. The specified billing account cannot be a subaccount, since a subaccount always belongs to the same organization as its parent account.
3857 ///
3858 /// Sets the *name* path property to the given value.
3859 ///
3860 /// Even though the property as already been set when instantiating this call,
3861 /// we provide this method for API completeness.
3862 pub fn name(mut self, new_value: &str) -> BillingAccountMoveCall<'a, C> {
3863 self._name = new_value.to_string();
3864 self
3865 }
3866 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3867 /// while executing the actual API request.
3868 ///
3869 /// ````text
3870 /// It should be used to handle progress information, and to implement a certain level of resilience.
3871 /// ````
3872 ///
3873 /// Sets the *delegate* property to the given value.
3874 pub fn delegate(
3875 mut self,
3876 new_value: &'a mut dyn common::Delegate,
3877 ) -> BillingAccountMoveCall<'a, C> {
3878 self._delegate = Some(new_value);
3879 self
3880 }
3881
3882 /// Set any additional parameter of the query string used in the request.
3883 /// It should be used to set parameters which are not yet available through their own
3884 /// setters.
3885 ///
3886 /// Please note that this method must not be used to set any of the known parameters
3887 /// which have their own setter method. If done anyway, the request will fail.
3888 ///
3889 /// # Additional Parameters
3890 ///
3891 /// * *$.xgafv* (query-string) - V1 error format.
3892 /// * *access_token* (query-string) - OAuth access token.
3893 /// * *alt* (query-string) - Data format for response.
3894 /// * *callback* (query-string) - JSONP
3895 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3896 /// * *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.
3897 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3898 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3899 /// * *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.
3900 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3901 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3902 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountMoveCall<'a, C>
3903 where
3904 T: AsRef<str>,
3905 {
3906 self._additional_params
3907 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3908 self
3909 }
3910
3911 /// Identifies the authorization scope for the method you are building.
3912 ///
3913 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3914 /// [`Scope::CloudPlatform`].
3915 ///
3916 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3917 /// tokens for more than one scope.
3918 ///
3919 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3920 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3921 /// sufficient, a read-write scope will do as well.
3922 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountMoveCall<'a, C>
3923 where
3924 St: AsRef<str>,
3925 {
3926 self._scopes.insert(String::from(scope.as_ref()));
3927 self
3928 }
3929 /// Identifies the authorization scope(s) for the method you are building.
3930 ///
3931 /// See [`Self::add_scope()`] for details.
3932 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountMoveCall<'a, C>
3933 where
3934 I: IntoIterator<Item = St>,
3935 St: AsRef<str>,
3936 {
3937 self._scopes
3938 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3939 self
3940 }
3941
3942 /// Removes all scopes, and no default scope will be used either.
3943 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3944 /// for details).
3945 pub fn clear_scopes(mut self) -> BillingAccountMoveCall<'a, C> {
3946 self._scopes.clear();
3947 self
3948 }
3949}
3950
3951/// Updates a billing account's fields. Currently the only field that can be edited is `display_name`. The current authenticated user must have the `billing.accounts.update` IAM permission, which is typically given to the [administrator](https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.
3952///
3953/// A builder for the *patch* method supported by a *billingAccount* resource.
3954/// It is not used directly, but through a [`BillingAccountMethods`] instance.
3955///
3956/// # Example
3957///
3958/// Instantiate a resource method builder
3959///
3960/// ```test_harness,no_run
3961/// # extern crate hyper;
3962/// # extern crate hyper_rustls;
3963/// # extern crate google_cloudbilling1 as cloudbilling1;
3964/// use cloudbilling1::api::BillingAccount;
3965/// # async fn dox() {
3966/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3967///
3968/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3969/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3970/// # .with_native_roots()
3971/// # .unwrap()
3972/// # .https_only()
3973/// # .enable_http2()
3974/// # .build();
3975///
3976/// # let executor = hyper_util::rt::TokioExecutor::new();
3977/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3978/// # secret,
3979/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3980/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3981/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3982/// # ),
3983/// # ).build().await.unwrap();
3984///
3985/// # let client = hyper_util::client::legacy::Client::builder(
3986/// # hyper_util::rt::TokioExecutor::new()
3987/// # )
3988/// # .build(
3989/// # hyper_rustls::HttpsConnectorBuilder::new()
3990/// # .with_native_roots()
3991/// # .unwrap()
3992/// # .https_or_http()
3993/// # .enable_http2()
3994/// # .build()
3995/// # );
3996/// # let mut hub = Cloudbilling::new(client, auth);
3997/// // As the method needs a request, you would usually fill it with the desired information
3998/// // into the respective structure. Some of the parts shown here might not be applicable !
3999/// // Values shown here are possibly random and not representative !
4000/// let mut req = BillingAccount::default();
4001///
4002/// // You can configure optional parameters by calling the respective setters at will, and
4003/// // execute the final call using `doit()`.
4004/// // Values shown here are possibly random and not representative !
4005/// let result = hub.billing_accounts().patch(req, "name")
4006/// .update_mask(FieldMask::new::<&str>(&[]))
4007/// .doit().await;
4008/// # }
4009/// ```
4010pub struct BillingAccountPatchCall<'a, C>
4011where
4012 C: 'a,
4013{
4014 hub: &'a Cloudbilling<C>,
4015 _request: BillingAccount,
4016 _name: String,
4017 _update_mask: Option<common::FieldMask>,
4018 _delegate: Option<&'a mut dyn common::Delegate>,
4019 _additional_params: HashMap<String, String>,
4020 _scopes: BTreeSet<String>,
4021}
4022
4023impl<'a, C> common::CallBuilder for BillingAccountPatchCall<'a, C> {}
4024
4025impl<'a, C> BillingAccountPatchCall<'a, C>
4026where
4027 C: common::Connector,
4028{
4029 /// Perform the operation you have build so far.
4030 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
4031 use std::borrow::Cow;
4032 use std::io::{Read, Seek};
4033
4034 use common::{url::Params, ToParts};
4035 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4036
4037 let mut dd = common::DefaultDelegate;
4038 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4039 dlg.begin(common::MethodInfo {
4040 id: "cloudbilling.billingAccounts.patch",
4041 http_method: hyper::Method::PATCH,
4042 });
4043
4044 for &field in ["alt", "name", "updateMask"].iter() {
4045 if self._additional_params.contains_key(field) {
4046 dlg.finished(false);
4047 return Err(common::Error::FieldClash(field));
4048 }
4049 }
4050
4051 let mut params = Params::with_capacity(5 + self._additional_params.len());
4052 params.push("name", self._name);
4053 if let Some(value) = self._update_mask.as_ref() {
4054 params.push("updateMask", value.to_string());
4055 }
4056
4057 params.extend(self._additional_params.iter());
4058
4059 params.push("alt", "json");
4060 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4061 if self._scopes.is_empty() {
4062 self._scopes
4063 .insert(Scope::CloudPlatform.as_ref().to_string());
4064 }
4065
4066 #[allow(clippy::single_element_loop)]
4067 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4068 url = params.uri_replacement(url, param_name, find_this, true);
4069 }
4070 {
4071 let to_remove = ["name"];
4072 params.remove_params(&to_remove);
4073 }
4074
4075 let url = params.parse_with_url(&url);
4076
4077 let mut json_mime_type = mime::APPLICATION_JSON;
4078 let mut request_value_reader = {
4079 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4080 common::remove_json_null_values(&mut value);
4081 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4082 serde_json::to_writer(&mut dst, &value).unwrap();
4083 dst
4084 };
4085 let request_size = request_value_reader
4086 .seek(std::io::SeekFrom::End(0))
4087 .unwrap();
4088 request_value_reader
4089 .seek(std::io::SeekFrom::Start(0))
4090 .unwrap();
4091
4092 loop {
4093 let token = match self
4094 .hub
4095 .auth
4096 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4097 .await
4098 {
4099 Ok(token) => token,
4100 Err(e) => match dlg.token(e) {
4101 Ok(token) => token,
4102 Err(e) => {
4103 dlg.finished(false);
4104 return Err(common::Error::MissingToken(e));
4105 }
4106 },
4107 };
4108 request_value_reader
4109 .seek(std::io::SeekFrom::Start(0))
4110 .unwrap();
4111 let mut req_result = {
4112 let client = &self.hub.client;
4113 dlg.pre_request();
4114 let mut req_builder = hyper::Request::builder()
4115 .method(hyper::Method::PATCH)
4116 .uri(url.as_str())
4117 .header(USER_AGENT, self.hub._user_agent.clone());
4118
4119 if let Some(token) = token.as_ref() {
4120 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4121 }
4122
4123 let request = req_builder
4124 .header(CONTENT_TYPE, json_mime_type.to_string())
4125 .header(CONTENT_LENGTH, request_size as u64)
4126 .body(common::to_body(
4127 request_value_reader.get_ref().clone().into(),
4128 ));
4129
4130 client.request(request.unwrap()).await
4131 };
4132
4133 match req_result {
4134 Err(err) => {
4135 if let common::Retry::After(d) = dlg.http_error(&err) {
4136 sleep(d).await;
4137 continue;
4138 }
4139 dlg.finished(false);
4140 return Err(common::Error::HttpError(err));
4141 }
4142 Ok(res) => {
4143 let (mut parts, body) = res.into_parts();
4144 let mut body = common::Body::new(body);
4145 if !parts.status.is_success() {
4146 let bytes = common::to_bytes(body).await.unwrap_or_default();
4147 let error = serde_json::from_str(&common::to_string(&bytes));
4148 let response = common::to_response(parts, bytes.into());
4149
4150 if let common::Retry::After(d) =
4151 dlg.http_failure(&response, error.as_ref().ok())
4152 {
4153 sleep(d).await;
4154 continue;
4155 }
4156
4157 dlg.finished(false);
4158
4159 return Err(match error {
4160 Ok(value) => common::Error::BadRequest(value),
4161 _ => common::Error::Failure(response),
4162 });
4163 }
4164 let response = {
4165 let bytes = common::to_bytes(body).await.unwrap_or_default();
4166 let encoded = common::to_string(&bytes);
4167 match serde_json::from_str(&encoded) {
4168 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4169 Err(error) => {
4170 dlg.response_json_decode_error(&encoded, &error);
4171 return Err(common::Error::JsonDecodeError(
4172 encoded.to_string(),
4173 error,
4174 ));
4175 }
4176 }
4177 };
4178
4179 dlg.finished(true);
4180 return Ok(response);
4181 }
4182 }
4183 }
4184 }
4185
4186 ///
4187 /// Sets the *request* property to the given value.
4188 ///
4189 /// Even though the property as already been set when instantiating this call,
4190 /// we provide this method for API completeness.
4191 pub fn request(mut self, new_value: BillingAccount) -> BillingAccountPatchCall<'a, C> {
4192 self._request = new_value;
4193 self
4194 }
4195 /// Required. The name of the billing account resource to be updated.
4196 ///
4197 /// Sets the *name* path property to the given value.
4198 ///
4199 /// Even though the property as already been set when instantiating this call,
4200 /// we provide this method for API completeness.
4201 pub fn name(mut self, new_value: &str) -> BillingAccountPatchCall<'a, C> {
4202 self._name = new_value.to_string();
4203 self
4204 }
4205 /// The update mask applied to the resource. Only "display_name" is currently supported.
4206 ///
4207 /// Sets the *update mask* query property to the given value.
4208 pub fn update_mask(mut self, new_value: common::FieldMask) -> BillingAccountPatchCall<'a, C> {
4209 self._update_mask = Some(new_value);
4210 self
4211 }
4212 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4213 /// while executing the actual API request.
4214 ///
4215 /// ````text
4216 /// It should be used to handle progress information, and to implement a certain level of resilience.
4217 /// ````
4218 ///
4219 /// Sets the *delegate* property to the given value.
4220 pub fn delegate(
4221 mut self,
4222 new_value: &'a mut dyn common::Delegate,
4223 ) -> BillingAccountPatchCall<'a, C> {
4224 self._delegate = Some(new_value);
4225 self
4226 }
4227
4228 /// Set any additional parameter of the query string used in the request.
4229 /// It should be used to set parameters which are not yet available through their own
4230 /// setters.
4231 ///
4232 /// Please note that this method must not be used to set any of the known parameters
4233 /// which have their own setter method. If done anyway, the request will fail.
4234 ///
4235 /// # Additional Parameters
4236 ///
4237 /// * *$.xgafv* (query-string) - V1 error format.
4238 /// * *access_token* (query-string) - OAuth access token.
4239 /// * *alt* (query-string) - Data format for response.
4240 /// * *callback* (query-string) - JSONP
4241 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4242 /// * *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.
4243 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4244 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4245 /// * *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.
4246 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4247 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4248 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountPatchCall<'a, C>
4249 where
4250 T: AsRef<str>,
4251 {
4252 self._additional_params
4253 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4254 self
4255 }
4256
4257 /// Identifies the authorization scope for the method you are building.
4258 ///
4259 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4260 /// [`Scope::CloudPlatform`].
4261 ///
4262 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4263 /// tokens for more than one scope.
4264 ///
4265 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4266 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4267 /// sufficient, a read-write scope will do as well.
4268 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountPatchCall<'a, C>
4269 where
4270 St: AsRef<str>,
4271 {
4272 self._scopes.insert(String::from(scope.as_ref()));
4273 self
4274 }
4275 /// Identifies the authorization scope(s) for the method you are building.
4276 ///
4277 /// See [`Self::add_scope()`] for details.
4278 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountPatchCall<'a, C>
4279 where
4280 I: IntoIterator<Item = St>,
4281 St: AsRef<str>,
4282 {
4283 self._scopes
4284 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4285 self
4286 }
4287
4288 /// Removes all scopes, and no default scope will be used either.
4289 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4290 /// for details).
4291 pub fn clear_scopes(mut self) -> BillingAccountPatchCall<'a, C> {
4292 self._scopes.clear();
4293 self
4294 }
4295}
4296
4297/// Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the `billing.accounts.setIamPolicy` permission on the account, which is often given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
4298///
4299/// A builder for the *setIamPolicy* method supported by a *billingAccount* resource.
4300/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4301///
4302/// # Example
4303///
4304/// Instantiate a resource method builder
4305///
4306/// ```test_harness,no_run
4307/// # extern crate hyper;
4308/// # extern crate hyper_rustls;
4309/// # extern crate google_cloudbilling1 as cloudbilling1;
4310/// use cloudbilling1::api::SetIamPolicyRequest;
4311/// # async fn dox() {
4312/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4313///
4314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4316/// # .with_native_roots()
4317/// # .unwrap()
4318/// # .https_only()
4319/// # .enable_http2()
4320/// # .build();
4321///
4322/// # let executor = hyper_util::rt::TokioExecutor::new();
4323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4324/// # secret,
4325/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4326/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4327/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4328/// # ),
4329/// # ).build().await.unwrap();
4330///
4331/// # let client = hyper_util::client::legacy::Client::builder(
4332/// # hyper_util::rt::TokioExecutor::new()
4333/// # )
4334/// # .build(
4335/// # hyper_rustls::HttpsConnectorBuilder::new()
4336/// # .with_native_roots()
4337/// # .unwrap()
4338/// # .https_or_http()
4339/// # .enable_http2()
4340/// # .build()
4341/// # );
4342/// # let mut hub = Cloudbilling::new(client, auth);
4343/// // As the method needs a request, you would usually fill it with the desired information
4344/// // into the respective structure. Some of the parts shown here might not be applicable !
4345/// // Values shown here are possibly random and not representative !
4346/// let mut req = SetIamPolicyRequest::default();
4347///
4348/// // You can configure optional parameters by calling the respective setters at will, and
4349/// // execute the final call using `doit()`.
4350/// // Values shown here are possibly random and not representative !
4351/// let result = hub.billing_accounts().set_iam_policy(req, "resource")
4352/// .doit().await;
4353/// # }
4354/// ```
4355pub struct BillingAccountSetIamPolicyCall<'a, C>
4356where
4357 C: 'a,
4358{
4359 hub: &'a Cloudbilling<C>,
4360 _request: SetIamPolicyRequest,
4361 _resource: String,
4362 _delegate: Option<&'a mut dyn common::Delegate>,
4363 _additional_params: HashMap<String, String>,
4364 _scopes: BTreeSet<String>,
4365}
4366
4367impl<'a, C> common::CallBuilder for BillingAccountSetIamPolicyCall<'a, C> {}
4368
4369impl<'a, C> BillingAccountSetIamPolicyCall<'a, C>
4370where
4371 C: common::Connector,
4372{
4373 /// Perform the operation you have build so far.
4374 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4375 use std::borrow::Cow;
4376 use std::io::{Read, Seek};
4377
4378 use common::{url::Params, ToParts};
4379 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4380
4381 let mut dd = common::DefaultDelegate;
4382 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4383 dlg.begin(common::MethodInfo {
4384 id: "cloudbilling.billingAccounts.setIamPolicy",
4385 http_method: hyper::Method::POST,
4386 });
4387
4388 for &field in ["alt", "resource"].iter() {
4389 if self._additional_params.contains_key(field) {
4390 dlg.finished(false);
4391 return Err(common::Error::FieldClash(field));
4392 }
4393 }
4394
4395 let mut params = Params::with_capacity(4 + self._additional_params.len());
4396 params.push("resource", self._resource);
4397
4398 params.extend(self._additional_params.iter());
4399
4400 params.push("alt", "json");
4401 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
4402 if self._scopes.is_empty() {
4403 self._scopes
4404 .insert(Scope::CloudPlatform.as_ref().to_string());
4405 }
4406
4407 #[allow(clippy::single_element_loop)]
4408 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4409 url = params.uri_replacement(url, param_name, find_this, true);
4410 }
4411 {
4412 let to_remove = ["resource"];
4413 params.remove_params(&to_remove);
4414 }
4415
4416 let url = params.parse_with_url(&url);
4417
4418 let mut json_mime_type = mime::APPLICATION_JSON;
4419 let mut request_value_reader = {
4420 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4421 common::remove_json_null_values(&mut value);
4422 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4423 serde_json::to_writer(&mut dst, &value).unwrap();
4424 dst
4425 };
4426 let request_size = request_value_reader
4427 .seek(std::io::SeekFrom::End(0))
4428 .unwrap();
4429 request_value_reader
4430 .seek(std::io::SeekFrom::Start(0))
4431 .unwrap();
4432
4433 loop {
4434 let token = match self
4435 .hub
4436 .auth
4437 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4438 .await
4439 {
4440 Ok(token) => token,
4441 Err(e) => match dlg.token(e) {
4442 Ok(token) => token,
4443 Err(e) => {
4444 dlg.finished(false);
4445 return Err(common::Error::MissingToken(e));
4446 }
4447 },
4448 };
4449 request_value_reader
4450 .seek(std::io::SeekFrom::Start(0))
4451 .unwrap();
4452 let mut req_result = {
4453 let client = &self.hub.client;
4454 dlg.pre_request();
4455 let mut req_builder = hyper::Request::builder()
4456 .method(hyper::Method::POST)
4457 .uri(url.as_str())
4458 .header(USER_AGENT, self.hub._user_agent.clone());
4459
4460 if let Some(token) = token.as_ref() {
4461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4462 }
4463
4464 let request = req_builder
4465 .header(CONTENT_TYPE, json_mime_type.to_string())
4466 .header(CONTENT_LENGTH, request_size as u64)
4467 .body(common::to_body(
4468 request_value_reader.get_ref().clone().into(),
4469 ));
4470
4471 client.request(request.unwrap()).await
4472 };
4473
4474 match req_result {
4475 Err(err) => {
4476 if let common::Retry::After(d) = dlg.http_error(&err) {
4477 sleep(d).await;
4478 continue;
4479 }
4480 dlg.finished(false);
4481 return Err(common::Error::HttpError(err));
4482 }
4483 Ok(res) => {
4484 let (mut parts, body) = res.into_parts();
4485 let mut body = common::Body::new(body);
4486 if !parts.status.is_success() {
4487 let bytes = common::to_bytes(body).await.unwrap_or_default();
4488 let error = serde_json::from_str(&common::to_string(&bytes));
4489 let response = common::to_response(parts, bytes.into());
4490
4491 if let common::Retry::After(d) =
4492 dlg.http_failure(&response, error.as_ref().ok())
4493 {
4494 sleep(d).await;
4495 continue;
4496 }
4497
4498 dlg.finished(false);
4499
4500 return Err(match error {
4501 Ok(value) => common::Error::BadRequest(value),
4502 _ => common::Error::Failure(response),
4503 });
4504 }
4505 let response = {
4506 let bytes = common::to_bytes(body).await.unwrap_or_default();
4507 let encoded = common::to_string(&bytes);
4508 match serde_json::from_str(&encoded) {
4509 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4510 Err(error) => {
4511 dlg.response_json_decode_error(&encoded, &error);
4512 return Err(common::Error::JsonDecodeError(
4513 encoded.to_string(),
4514 error,
4515 ));
4516 }
4517 }
4518 };
4519
4520 dlg.finished(true);
4521 return Ok(response);
4522 }
4523 }
4524 }
4525 }
4526
4527 ///
4528 /// Sets the *request* property to the given value.
4529 ///
4530 /// Even though the property as already been set when instantiating this call,
4531 /// we provide this method for API completeness.
4532 pub fn request(
4533 mut self,
4534 new_value: SetIamPolicyRequest,
4535 ) -> BillingAccountSetIamPolicyCall<'a, C> {
4536 self._request = new_value;
4537 self
4538 }
4539 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
4540 ///
4541 /// Sets the *resource* path property to the given value.
4542 ///
4543 /// Even though the property as already been set when instantiating this call,
4544 /// we provide this method for API completeness.
4545 pub fn resource(mut self, new_value: &str) -> BillingAccountSetIamPolicyCall<'a, C> {
4546 self._resource = new_value.to_string();
4547 self
4548 }
4549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4550 /// while executing the actual API request.
4551 ///
4552 /// ````text
4553 /// It should be used to handle progress information, and to implement a certain level of resilience.
4554 /// ````
4555 ///
4556 /// Sets the *delegate* property to the given value.
4557 pub fn delegate(
4558 mut self,
4559 new_value: &'a mut dyn common::Delegate,
4560 ) -> BillingAccountSetIamPolicyCall<'a, C> {
4561 self._delegate = Some(new_value);
4562 self
4563 }
4564
4565 /// Set any additional parameter of the query string used in the request.
4566 /// It should be used to set parameters which are not yet available through their own
4567 /// setters.
4568 ///
4569 /// Please note that this method must not be used to set any of the known parameters
4570 /// which have their own setter method. If done anyway, the request will fail.
4571 ///
4572 /// # Additional Parameters
4573 ///
4574 /// * *$.xgafv* (query-string) - V1 error format.
4575 /// * *access_token* (query-string) - OAuth access token.
4576 /// * *alt* (query-string) - Data format for response.
4577 /// * *callback* (query-string) - JSONP
4578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4579 /// * *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.
4580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4582 /// * *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.
4583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4585 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountSetIamPolicyCall<'a, C>
4586 where
4587 T: AsRef<str>,
4588 {
4589 self._additional_params
4590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4591 self
4592 }
4593
4594 /// Identifies the authorization scope for the method you are building.
4595 ///
4596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4597 /// [`Scope::CloudPlatform`].
4598 ///
4599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4600 /// tokens for more than one scope.
4601 ///
4602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4604 /// sufficient, a read-write scope will do as well.
4605 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountSetIamPolicyCall<'a, C>
4606 where
4607 St: AsRef<str>,
4608 {
4609 self._scopes.insert(String::from(scope.as_ref()));
4610 self
4611 }
4612 /// Identifies the authorization scope(s) for the method you are building.
4613 ///
4614 /// See [`Self::add_scope()`] for details.
4615 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountSetIamPolicyCall<'a, C>
4616 where
4617 I: IntoIterator<Item = St>,
4618 St: AsRef<str>,
4619 {
4620 self._scopes
4621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4622 self
4623 }
4624
4625 /// Removes all scopes, and no default scope will be used either.
4626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4627 /// for details).
4628 pub fn clear_scopes(mut self) -> BillingAccountSetIamPolicyCall<'a, C> {
4629 self._scopes.clear();
4630 self
4631 }
4632}
4633
4634/// Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.
4635///
4636/// A builder for the *testIamPermissions* method supported by a *billingAccount* resource.
4637/// It is not used directly, but through a [`BillingAccountMethods`] instance.
4638///
4639/// # Example
4640///
4641/// Instantiate a resource method builder
4642///
4643/// ```test_harness,no_run
4644/// # extern crate hyper;
4645/// # extern crate hyper_rustls;
4646/// # extern crate google_cloudbilling1 as cloudbilling1;
4647/// use cloudbilling1::api::TestIamPermissionsRequest;
4648/// # async fn dox() {
4649/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4650///
4651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4653/// # .with_native_roots()
4654/// # .unwrap()
4655/// # .https_only()
4656/// # .enable_http2()
4657/// # .build();
4658///
4659/// # let executor = hyper_util::rt::TokioExecutor::new();
4660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4661/// # secret,
4662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4665/// # ),
4666/// # ).build().await.unwrap();
4667///
4668/// # let client = hyper_util::client::legacy::Client::builder(
4669/// # hyper_util::rt::TokioExecutor::new()
4670/// # )
4671/// # .build(
4672/// # hyper_rustls::HttpsConnectorBuilder::new()
4673/// # .with_native_roots()
4674/// # .unwrap()
4675/// # .https_or_http()
4676/// # .enable_http2()
4677/// # .build()
4678/// # );
4679/// # let mut hub = Cloudbilling::new(client, auth);
4680/// // As the method needs a request, you would usually fill it with the desired information
4681/// // into the respective structure. Some of the parts shown here might not be applicable !
4682/// // Values shown here are possibly random and not representative !
4683/// let mut req = TestIamPermissionsRequest::default();
4684///
4685/// // You can configure optional parameters by calling the respective setters at will, and
4686/// // execute the final call using `doit()`.
4687/// // Values shown here are possibly random and not representative !
4688/// let result = hub.billing_accounts().test_iam_permissions(req, "resource")
4689/// .doit().await;
4690/// # }
4691/// ```
4692pub struct BillingAccountTestIamPermissionCall<'a, C>
4693where
4694 C: 'a,
4695{
4696 hub: &'a Cloudbilling<C>,
4697 _request: TestIamPermissionsRequest,
4698 _resource: String,
4699 _delegate: Option<&'a mut dyn common::Delegate>,
4700 _additional_params: HashMap<String, String>,
4701 _scopes: BTreeSet<String>,
4702}
4703
4704impl<'a, C> common::CallBuilder for BillingAccountTestIamPermissionCall<'a, C> {}
4705
4706impl<'a, C> BillingAccountTestIamPermissionCall<'a, C>
4707where
4708 C: common::Connector,
4709{
4710 /// Perform the operation you have build so far.
4711 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4712 use std::borrow::Cow;
4713 use std::io::{Read, Seek};
4714
4715 use common::{url::Params, ToParts};
4716 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4717
4718 let mut dd = common::DefaultDelegate;
4719 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4720 dlg.begin(common::MethodInfo {
4721 id: "cloudbilling.billingAccounts.testIamPermissions",
4722 http_method: hyper::Method::POST,
4723 });
4724
4725 for &field in ["alt", "resource"].iter() {
4726 if self._additional_params.contains_key(field) {
4727 dlg.finished(false);
4728 return Err(common::Error::FieldClash(field));
4729 }
4730 }
4731
4732 let mut params = Params::with_capacity(4 + self._additional_params.len());
4733 params.push("resource", self._resource);
4734
4735 params.extend(self._additional_params.iter());
4736
4737 params.push("alt", "json");
4738 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
4739 if self._scopes.is_empty() {
4740 self._scopes
4741 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
4742 }
4743
4744 #[allow(clippy::single_element_loop)]
4745 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4746 url = params.uri_replacement(url, param_name, find_this, true);
4747 }
4748 {
4749 let to_remove = ["resource"];
4750 params.remove_params(&to_remove);
4751 }
4752
4753 let url = params.parse_with_url(&url);
4754
4755 let mut json_mime_type = mime::APPLICATION_JSON;
4756 let mut request_value_reader = {
4757 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4758 common::remove_json_null_values(&mut value);
4759 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4760 serde_json::to_writer(&mut dst, &value).unwrap();
4761 dst
4762 };
4763 let request_size = request_value_reader
4764 .seek(std::io::SeekFrom::End(0))
4765 .unwrap();
4766 request_value_reader
4767 .seek(std::io::SeekFrom::Start(0))
4768 .unwrap();
4769
4770 loop {
4771 let token = match self
4772 .hub
4773 .auth
4774 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4775 .await
4776 {
4777 Ok(token) => token,
4778 Err(e) => match dlg.token(e) {
4779 Ok(token) => token,
4780 Err(e) => {
4781 dlg.finished(false);
4782 return Err(common::Error::MissingToken(e));
4783 }
4784 },
4785 };
4786 request_value_reader
4787 .seek(std::io::SeekFrom::Start(0))
4788 .unwrap();
4789 let mut req_result = {
4790 let client = &self.hub.client;
4791 dlg.pre_request();
4792 let mut req_builder = hyper::Request::builder()
4793 .method(hyper::Method::POST)
4794 .uri(url.as_str())
4795 .header(USER_AGENT, self.hub._user_agent.clone());
4796
4797 if let Some(token) = token.as_ref() {
4798 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4799 }
4800
4801 let request = req_builder
4802 .header(CONTENT_TYPE, json_mime_type.to_string())
4803 .header(CONTENT_LENGTH, request_size as u64)
4804 .body(common::to_body(
4805 request_value_reader.get_ref().clone().into(),
4806 ));
4807
4808 client.request(request.unwrap()).await
4809 };
4810
4811 match req_result {
4812 Err(err) => {
4813 if let common::Retry::After(d) = dlg.http_error(&err) {
4814 sleep(d).await;
4815 continue;
4816 }
4817 dlg.finished(false);
4818 return Err(common::Error::HttpError(err));
4819 }
4820 Ok(res) => {
4821 let (mut parts, body) = res.into_parts();
4822 let mut body = common::Body::new(body);
4823 if !parts.status.is_success() {
4824 let bytes = common::to_bytes(body).await.unwrap_or_default();
4825 let error = serde_json::from_str(&common::to_string(&bytes));
4826 let response = common::to_response(parts, bytes.into());
4827
4828 if let common::Retry::After(d) =
4829 dlg.http_failure(&response, error.as_ref().ok())
4830 {
4831 sleep(d).await;
4832 continue;
4833 }
4834
4835 dlg.finished(false);
4836
4837 return Err(match error {
4838 Ok(value) => common::Error::BadRequest(value),
4839 _ => common::Error::Failure(response),
4840 });
4841 }
4842 let response = {
4843 let bytes = common::to_bytes(body).await.unwrap_or_default();
4844 let encoded = common::to_string(&bytes);
4845 match serde_json::from_str(&encoded) {
4846 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4847 Err(error) => {
4848 dlg.response_json_decode_error(&encoded, &error);
4849 return Err(common::Error::JsonDecodeError(
4850 encoded.to_string(),
4851 error,
4852 ));
4853 }
4854 }
4855 };
4856
4857 dlg.finished(true);
4858 return Ok(response);
4859 }
4860 }
4861 }
4862 }
4863
4864 ///
4865 /// Sets the *request* property to the given value.
4866 ///
4867 /// Even though the property as already been set when instantiating this call,
4868 /// we provide this method for API completeness.
4869 pub fn request(
4870 mut self,
4871 new_value: TestIamPermissionsRequest,
4872 ) -> BillingAccountTestIamPermissionCall<'a, C> {
4873 self._request = new_value;
4874 self
4875 }
4876 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
4877 ///
4878 /// Sets the *resource* path property to the given value.
4879 ///
4880 /// Even though the property as already been set when instantiating this call,
4881 /// we provide this method for API completeness.
4882 pub fn resource(mut self, new_value: &str) -> BillingAccountTestIamPermissionCall<'a, C> {
4883 self._resource = new_value.to_string();
4884 self
4885 }
4886 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4887 /// while executing the actual API request.
4888 ///
4889 /// ````text
4890 /// It should be used to handle progress information, and to implement a certain level of resilience.
4891 /// ````
4892 ///
4893 /// Sets the *delegate* property to the given value.
4894 pub fn delegate(
4895 mut self,
4896 new_value: &'a mut dyn common::Delegate,
4897 ) -> BillingAccountTestIamPermissionCall<'a, C> {
4898 self._delegate = Some(new_value);
4899 self
4900 }
4901
4902 /// Set any additional parameter of the query string used in the request.
4903 /// It should be used to set parameters which are not yet available through their own
4904 /// setters.
4905 ///
4906 /// Please note that this method must not be used to set any of the known parameters
4907 /// which have their own setter method. If done anyway, the request will fail.
4908 ///
4909 /// # Additional Parameters
4910 ///
4911 /// * *$.xgafv* (query-string) - V1 error format.
4912 /// * *access_token* (query-string) - OAuth access token.
4913 /// * *alt* (query-string) - Data format for response.
4914 /// * *callback* (query-string) - JSONP
4915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4916 /// * *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.
4917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4919 /// * *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.
4920 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4921 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4922 pub fn param<T>(mut self, name: T, value: T) -> BillingAccountTestIamPermissionCall<'a, C>
4923 where
4924 T: AsRef<str>,
4925 {
4926 self._additional_params
4927 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4928 self
4929 }
4930
4931 /// Identifies the authorization scope for the method you are building.
4932 ///
4933 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4934 /// [`Scope::CloudBillingReadonly`].
4935 ///
4936 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4937 /// tokens for more than one scope.
4938 ///
4939 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4940 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4941 /// sufficient, a read-write scope will do as well.
4942 pub fn add_scope<St>(mut self, scope: St) -> BillingAccountTestIamPermissionCall<'a, C>
4943 where
4944 St: AsRef<str>,
4945 {
4946 self._scopes.insert(String::from(scope.as_ref()));
4947 self
4948 }
4949 /// Identifies the authorization scope(s) for the method you are building.
4950 ///
4951 /// See [`Self::add_scope()`] for details.
4952 pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingAccountTestIamPermissionCall<'a, C>
4953 where
4954 I: IntoIterator<Item = St>,
4955 St: AsRef<str>,
4956 {
4957 self._scopes
4958 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4959 self
4960 }
4961
4962 /// Removes all scopes, and no default scope will be used either.
4963 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4964 /// for details).
4965 pub fn clear_scopes(mut self) -> BillingAccountTestIamPermissionCall<'a, C> {
4966 self._scopes.clear();
4967 self
4968 }
4969}
4970
4971/// This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned for subaccounts.
4972///
4973/// A builder for the *billingAccounts.create* method supported by a *organization* resource.
4974/// It is not used directly, but through a [`OrganizationMethods`] instance.
4975///
4976/// # Example
4977///
4978/// Instantiate a resource method builder
4979///
4980/// ```test_harness,no_run
4981/// # extern crate hyper;
4982/// # extern crate hyper_rustls;
4983/// # extern crate google_cloudbilling1 as cloudbilling1;
4984/// use cloudbilling1::api::BillingAccount;
4985/// # async fn dox() {
4986/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4987///
4988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4990/// # .with_native_roots()
4991/// # .unwrap()
4992/// # .https_only()
4993/// # .enable_http2()
4994/// # .build();
4995///
4996/// # let executor = hyper_util::rt::TokioExecutor::new();
4997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4998/// # secret,
4999/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5000/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5001/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5002/// # ),
5003/// # ).build().await.unwrap();
5004///
5005/// # let client = hyper_util::client::legacy::Client::builder(
5006/// # hyper_util::rt::TokioExecutor::new()
5007/// # )
5008/// # .build(
5009/// # hyper_rustls::HttpsConnectorBuilder::new()
5010/// # .with_native_roots()
5011/// # .unwrap()
5012/// # .https_or_http()
5013/// # .enable_http2()
5014/// # .build()
5015/// # );
5016/// # let mut hub = Cloudbilling::new(client, auth);
5017/// // As the method needs a request, you would usually fill it with the desired information
5018/// // into the respective structure. Some of the parts shown here might not be applicable !
5019/// // Values shown here are possibly random and not representative !
5020/// let mut req = BillingAccount::default();
5021///
5022/// // You can configure optional parameters by calling the respective setters at will, and
5023/// // execute the final call using `doit()`.
5024/// // Values shown here are possibly random and not representative !
5025/// let result = hub.organizations().billing_accounts_create(req, "parent")
5026/// .doit().await;
5027/// # }
5028/// ```
5029pub struct OrganizationBillingAccountCreateCall<'a, C>
5030where
5031 C: 'a,
5032{
5033 hub: &'a Cloudbilling<C>,
5034 _request: BillingAccount,
5035 _parent: String,
5036 _delegate: Option<&'a mut dyn common::Delegate>,
5037 _additional_params: HashMap<String, String>,
5038 _scopes: BTreeSet<String>,
5039}
5040
5041impl<'a, C> common::CallBuilder for OrganizationBillingAccountCreateCall<'a, C> {}
5042
5043impl<'a, C> OrganizationBillingAccountCreateCall<'a, C>
5044where
5045 C: common::Connector,
5046{
5047 /// Perform the operation you have build so far.
5048 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
5049 use std::borrow::Cow;
5050 use std::io::{Read, Seek};
5051
5052 use common::{url::Params, ToParts};
5053 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5054
5055 let mut dd = common::DefaultDelegate;
5056 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5057 dlg.begin(common::MethodInfo {
5058 id: "cloudbilling.organizations.billingAccounts.create",
5059 http_method: hyper::Method::POST,
5060 });
5061
5062 for &field in ["alt", "parent"].iter() {
5063 if self._additional_params.contains_key(field) {
5064 dlg.finished(false);
5065 return Err(common::Error::FieldClash(field));
5066 }
5067 }
5068
5069 let mut params = Params::with_capacity(4 + self._additional_params.len());
5070 params.push("parent", self._parent);
5071
5072 params.extend(self._additional_params.iter());
5073
5074 params.push("alt", "json");
5075 let mut url = self.hub._base_url.clone() + "v1/{+parent}/billingAccounts";
5076 if self._scopes.is_empty() {
5077 self._scopes
5078 .insert(Scope::CloudPlatform.as_ref().to_string());
5079 }
5080
5081 #[allow(clippy::single_element_loop)]
5082 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5083 url = params.uri_replacement(url, param_name, find_this, true);
5084 }
5085 {
5086 let to_remove = ["parent"];
5087 params.remove_params(&to_remove);
5088 }
5089
5090 let url = params.parse_with_url(&url);
5091
5092 let mut json_mime_type = mime::APPLICATION_JSON;
5093 let mut request_value_reader = {
5094 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5095 common::remove_json_null_values(&mut value);
5096 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5097 serde_json::to_writer(&mut dst, &value).unwrap();
5098 dst
5099 };
5100 let request_size = request_value_reader
5101 .seek(std::io::SeekFrom::End(0))
5102 .unwrap();
5103 request_value_reader
5104 .seek(std::io::SeekFrom::Start(0))
5105 .unwrap();
5106
5107 loop {
5108 let token = match self
5109 .hub
5110 .auth
5111 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5112 .await
5113 {
5114 Ok(token) => token,
5115 Err(e) => match dlg.token(e) {
5116 Ok(token) => token,
5117 Err(e) => {
5118 dlg.finished(false);
5119 return Err(common::Error::MissingToken(e));
5120 }
5121 },
5122 };
5123 request_value_reader
5124 .seek(std::io::SeekFrom::Start(0))
5125 .unwrap();
5126 let mut req_result = {
5127 let client = &self.hub.client;
5128 dlg.pre_request();
5129 let mut req_builder = hyper::Request::builder()
5130 .method(hyper::Method::POST)
5131 .uri(url.as_str())
5132 .header(USER_AGENT, self.hub._user_agent.clone());
5133
5134 if let Some(token) = token.as_ref() {
5135 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5136 }
5137
5138 let request = req_builder
5139 .header(CONTENT_TYPE, json_mime_type.to_string())
5140 .header(CONTENT_LENGTH, request_size as u64)
5141 .body(common::to_body(
5142 request_value_reader.get_ref().clone().into(),
5143 ));
5144
5145 client.request(request.unwrap()).await
5146 };
5147
5148 match req_result {
5149 Err(err) => {
5150 if let common::Retry::After(d) = dlg.http_error(&err) {
5151 sleep(d).await;
5152 continue;
5153 }
5154 dlg.finished(false);
5155 return Err(common::Error::HttpError(err));
5156 }
5157 Ok(res) => {
5158 let (mut parts, body) = res.into_parts();
5159 let mut body = common::Body::new(body);
5160 if !parts.status.is_success() {
5161 let bytes = common::to_bytes(body).await.unwrap_or_default();
5162 let error = serde_json::from_str(&common::to_string(&bytes));
5163 let response = common::to_response(parts, bytes.into());
5164
5165 if let common::Retry::After(d) =
5166 dlg.http_failure(&response, error.as_ref().ok())
5167 {
5168 sleep(d).await;
5169 continue;
5170 }
5171
5172 dlg.finished(false);
5173
5174 return Err(match error {
5175 Ok(value) => common::Error::BadRequest(value),
5176 _ => common::Error::Failure(response),
5177 });
5178 }
5179 let response = {
5180 let bytes = common::to_bytes(body).await.unwrap_or_default();
5181 let encoded = common::to_string(&bytes);
5182 match serde_json::from_str(&encoded) {
5183 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5184 Err(error) => {
5185 dlg.response_json_decode_error(&encoded, &error);
5186 return Err(common::Error::JsonDecodeError(
5187 encoded.to_string(),
5188 error,
5189 ));
5190 }
5191 }
5192 };
5193
5194 dlg.finished(true);
5195 return Ok(response);
5196 }
5197 }
5198 }
5199 }
5200
5201 ///
5202 /// Sets the *request* property to the given value.
5203 ///
5204 /// Even though the property as already been set when instantiating this call,
5205 /// we provide this method for API completeness.
5206 pub fn request(
5207 mut self,
5208 new_value: BillingAccount,
5209 ) -> OrganizationBillingAccountCreateCall<'a, C> {
5210 self._request = new_value;
5211 self
5212 }
5213 /// Optional. The parent to create a billing account from. Format: - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
5214 ///
5215 /// Sets the *parent* path property to the given value.
5216 ///
5217 /// Even though the property as already been set when instantiating this call,
5218 /// we provide this method for API completeness.
5219 pub fn parent(mut self, new_value: &str) -> OrganizationBillingAccountCreateCall<'a, C> {
5220 self._parent = new_value.to_string();
5221 self
5222 }
5223 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5224 /// while executing the actual API request.
5225 ///
5226 /// ````text
5227 /// It should be used to handle progress information, and to implement a certain level of resilience.
5228 /// ````
5229 ///
5230 /// Sets the *delegate* property to the given value.
5231 pub fn delegate(
5232 mut self,
5233 new_value: &'a mut dyn common::Delegate,
5234 ) -> OrganizationBillingAccountCreateCall<'a, C> {
5235 self._delegate = Some(new_value);
5236 self
5237 }
5238
5239 /// Set any additional parameter of the query string used in the request.
5240 /// It should be used to set parameters which are not yet available through their own
5241 /// setters.
5242 ///
5243 /// Please note that this method must not be used to set any of the known parameters
5244 /// which have their own setter method. If done anyway, the request will fail.
5245 ///
5246 /// # Additional Parameters
5247 ///
5248 /// * *$.xgafv* (query-string) - V1 error format.
5249 /// * *access_token* (query-string) - OAuth access token.
5250 /// * *alt* (query-string) - Data format for response.
5251 /// * *callback* (query-string) - JSONP
5252 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5253 /// * *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.
5254 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5255 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5256 /// * *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.
5257 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5258 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5259 pub fn param<T>(mut self, name: T, value: T) -> OrganizationBillingAccountCreateCall<'a, C>
5260 where
5261 T: AsRef<str>,
5262 {
5263 self._additional_params
5264 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5265 self
5266 }
5267
5268 /// Identifies the authorization scope for the method you are building.
5269 ///
5270 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5271 /// [`Scope::CloudPlatform`].
5272 ///
5273 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5274 /// tokens for more than one scope.
5275 ///
5276 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5277 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5278 /// sufficient, a read-write scope will do as well.
5279 pub fn add_scope<St>(mut self, scope: St) -> OrganizationBillingAccountCreateCall<'a, C>
5280 where
5281 St: AsRef<str>,
5282 {
5283 self._scopes.insert(String::from(scope.as_ref()));
5284 self
5285 }
5286 /// Identifies the authorization scope(s) for the method you are building.
5287 ///
5288 /// See [`Self::add_scope()`] for details.
5289 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationBillingAccountCreateCall<'a, C>
5290 where
5291 I: IntoIterator<Item = St>,
5292 St: AsRef<str>,
5293 {
5294 self._scopes
5295 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5296 self
5297 }
5298
5299 /// Removes all scopes, and no default scope will be used either.
5300 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5301 /// for details).
5302 pub fn clear_scopes(mut self) -> OrganizationBillingAccountCreateCall<'a, C> {
5303 self._scopes.clear();
5304 self
5305 }
5306}
5307
5308/// Lists the billing accounts that the current authenticated user has permission to [view](https://cloud.google.com/billing/docs/how-to/billing-access).
5309///
5310/// A builder for the *billingAccounts.list* method supported by a *organization* resource.
5311/// It is not used directly, but through a [`OrganizationMethods`] instance.
5312///
5313/// # Example
5314///
5315/// Instantiate a resource method builder
5316///
5317/// ```test_harness,no_run
5318/// # extern crate hyper;
5319/// # extern crate hyper_rustls;
5320/// # extern crate google_cloudbilling1 as cloudbilling1;
5321/// # async fn dox() {
5322/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5323///
5324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5325/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5326/// # .with_native_roots()
5327/// # .unwrap()
5328/// # .https_only()
5329/// # .enable_http2()
5330/// # .build();
5331///
5332/// # let executor = hyper_util::rt::TokioExecutor::new();
5333/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5334/// # secret,
5335/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5336/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5337/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5338/// # ),
5339/// # ).build().await.unwrap();
5340///
5341/// # let client = hyper_util::client::legacy::Client::builder(
5342/// # hyper_util::rt::TokioExecutor::new()
5343/// # )
5344/// # .build(
5345/// # hyper_rustls::HttpsConnectorBuilder::new()
5346/// # .with_native_roots()
5347/// # .unwrap()
5348/// # .https_or_http()
5349/// # .enable_http2()
5350/// # .build()
5351/// # );
5352/// # let mut hub = Cloudbilling::new(client, auth);
5353/// // You can configure optional parameters by calling the respective setters at will, and
5354/// // execute the final call using `doit()`.
5355/// // Values shown here are possibly random and not representative !
5356/// let result = hub.organizations().billing_accounts_list("parent")
5357/// .page_token("dolor")
5358/// .page_size(-56)
5359/// .filter("eos")
5360/// .doit().await;
5361/// # }
5362/// ```
5363pub struct OrganizationBillingAccountListCall<'a, C>
5364where
5365 C: 'a,
5366{
5367 hub: &'a Cloudbilling<C>,
5368 _parent: String,
5369 _page_token: Option<String>,
5370 _page_size: Option<i32>,
5371 _filter: Option<String>,
5372 _delegate: Option<&'a mut dyn common::Delegate>,
5373 _additional_params: HashMap<String, String>,
5374 _scopes: BTreeSet<String>,
5375}
5376
5377impl<'a, C> common::CallBuilder for OrganizationBillingAccountListCall<'a, C> {}
5378
5379impl<'a, C> OrganizationBillingAccountListCall<'a, C>
5380where
5381 C: common::Connector,
5382{
5383 /// Perform the operation you have build so far.
5384 pub async fn doit(mut self) -> common::Result<(common::Response, ListBillingAccountsResponse)> {
5385 use std::borrow::Cow;
5386 use std::io::{Read, Seek};
5387
5388 use common::{url::Params, ToParts};
5389 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5390
5391 let mut dd = common::DefaultDelegate;
5392 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5393 dlg.begin(common::MethodInfo {
5394 id: "cloudbilling.organizations.billingAccounts.list",
5395 http_method: hyper::Method::GET,
5396 });
5397
5398 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5399 if self._additional_params.contains_key(field) {
5400 dlg.finished(false);
5401 return Err(common::Error::FieldClash(field));
5402 }
5403 }
5404
5405 let mut params = Params::with_capacity(6 + self._additional_params.len());
5406 params.push("parent", self._parent);
5407 if let Some(value) = self._page_token.as_ref() {
5408 params.push("pageToken", value);
5409 }
5410 if let Some(value) = self._page_size.as_ref() {
5411 params.push("pageSize", value.to_string());
5412 }
5413 if let Some(value) = self._filter.as_ref() {
5414 params.push("filter", value);
5415 }
5416
5417 params.extend(self._additional_params.iter());
5418
5419 params.push("alt", "json");
5420 let mut url = self.hub._base_url.clone() + "v1/{+parent}/billingAccounts";
5421 if self._scopes.is_empty() {
5422 self._scopes
5423 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
5424 }
5425
5426 #[allow(clippy::single_element_loop)]
5427 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5428 url = params.uri_replacement(url, param_name, find_this, true);
5429 }
5430 {
5431 let to_remove = ["parent"];
5432 params.remove_params(&to_remove);
5433 }
5434
5435 let url = params.parse_with_url(&url);
5436
5437 loop {
5438 let token = match self
5439 .hub
5440 .auth
5441 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5442 .await
5443 {
5444 Ok(token) => token,
5445 Err(e) => match dlg.token(e) {
5446 Ok(token) => token,
5447 Err(e) => {
5448 dlg.finished(false);
5449 return Err(common::Error::MissingToken(e));
5450 }
5451 },
5452 };
5453 let mut req_result = {
5454 let client = &self.hub.client;
5455 dlg.pre_request();
5456 let mut req_builder = hyper::Request::builder()
5457 .method(hyper::Method::GET)
5458 .uri(url.as_str())
5459 .header(USER_AGENT, self.hub._user_agent.clone());
5460
5461 if let Some(token) = token.as_ref() {
5462 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5463 }
5464
5465 let request = req_builder
5466 .header(CONTENT_LENGTH, 0_u64)
5467 .body(common::to_body::<String>(None));
5468
5469 client.request(request.unwrap()).await
5470 };
5471
5472 match req_result {
5473 Err(err) => {
5474 if let common::Retry::After(d) = dlg.http_error(&err) {
5475 sleep(d).await;
5476 continue;
5477 }
5478 dlg.finished(false);
5479 return Err(common::Error::HttpError(err));
5480 }
5481 Ok(res) => {
5482 let (mut parts, body) = res.into_parts();
5483 let mut body = common::Body::new(body);
5484 if !parts.status.is_success() {
5485 let bytes = common::to_bytes(body).await.unwrap_or_default();
5486 let error = serde_json::from_str(&common::to_string(&bytes));
5487 let response = common::to_response(parts, bytes.into());
5488
5489 if let common::Retry::After(d) =
5490 dlg.http_failure(&response, error.as_ref().ok())
5491 {
5492 sleep(d).await;
5493 continue;
5494 }
5495
5496 dlg.finished(false);
5497
5498 return Err(match error {
5499 Ok(value) => common::Error::BadRequest(value),
5500 _ => common::Error::Failure(response),
5501 });
5502 }
5503 let response = {
5504 let bytes = common::to_bytes(body).await.unwrap_or_default();
5505 let encoded = common::to_string(&bytes);
5506 match serde_json::from_str(&encoded) {
5507 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5508 Err(error) => {
5509 dlg.response_json_decode_error(&encoded, &error);
5510 return Err(common::Error::JsonDecodeError(
5511 encoded.to_string(),
5512 error,
5513 ));
5514 }
5515 }
5516 };
5517
5518 dlg.finished(true);
5519 return Ok(response);
5520 }
5521 }
5522 }
5523 }
5524
5525 /// Optional. The parent resource to list billing accounts from. Format: - `organizations/{organization_id}`, for example, `organizations/12345678` - `billingAccounts/{billing_account_id}`, for example, `billingAccounts/012345-567890-ABCDEF`
5526 ///
5527 /// Sets the *parent* path property to the given value.
5528 ///
5529 /// Even though the property as already been set when instantiating this call,
5530 /// we provide this method for API completeness.
5531 pub fn parent(mut self, new_value: &str) -> OrganizationBillingAccountListCall<'a, C> {
5532 self._parent = new_value.to_string();
5533 self
5534 }
5535 /// A token identifying a page of results to return. This should be a `next_page_token` value returned from a previous `ListBillingAccounts` call. If unspecified, the first page of results is returned.
5536 ///
5537 /// Sets the *page token* query property to the given value.
5538 pub fn page_token(mut self, new_value: &str) -> OrganizationBillingAccountListCall<'a, C> {
5539 self._page_token = Some(new_value.to_string());
5540 self
5541 }
5542 /// Requested page size. The maximum page size is 100; this is also the default.
5543 ///
5544 /// Sets the *page size* query property to the given value.
5545 pub fn page_size(mut self, new_value: i32) -> OrganizationBillingAccountListCall<'a, C> {
5546 self._page_size = Some(new_value);
5547 self
5548 }
5549 /// Options for how to filter the returned billing accounts. This only supports filtering for [subaccounts](https://cloud.google.com/billing/docs/concepts) under a single provided parent billing account. (for example, `master_billing_account=billingAccounts/012345-678901-ABCDEF`). Boolean algebra and other fields are not currently supported.
5550 ///
5551 /// Sets the *filter* query property to the given value.
5552 pub fn filter(mut self, new_value: &str) -> OrganizationBillingAccountListCall<'a, C> {
5553 self._filter = Some(new_value.to_string());
5554 self
5555 }
5556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5557 /// while executing the actual API request.
5558 ///
5559 /// ````text
5560 /// It should be used to handle progress information, and to implement a certain level of resilience.
5561 /// ````
5562 ///
5563 /// Sets the *delegate* property to the given value.
5564 pub fn delegate(
5565 mut self,
5566 new_value: &'a mut dyn common::Delegate,
5567 ) -> OrganizationBillingAccountListCall<'a, C> {
5568 self._delegate = Some(new_value);
5569 self
5570 }
5571
5572 /// Set any additional parameter of the query string used in the request.
5573 /// It should be used to set parameters which are not yet available through their own
5574 /// setters.
5575 ///
5576 /// Please note that this method must not be used to set any of the known parameters
5577 /// which have their own setter method. If done anyway, the request will fail.
5578 ///
5579 /// # Additional Parameters
5580 ///
5581 /// * *$.xgafv* (query-string) - V1 error format.
5582 /// * *access_token* (query-string) - OAuth access token.
5583 /// * *alt* (query-string) - Data format for response.
5584 /// * *callback* (query-string) - JSONP
5585 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5586 /// * *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.
5587 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5588 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5589 /// * *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.
5590 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5591 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5592 pub fn param<T>(mut self, name: T, value: T) -> OrganizationBillingAccountListCall<'a, C>
5593 where
5594 T: AsRef<str>,
5595 {
5596 self._additional_params
5597 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5598 self
5599 }
5600
5601 /// Identifies the authorization scope for the method you are building.
5602 ///
5603 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5604 /// [`Scope::CloudBillingReadonly`].
5605 ///
5606 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5607 /// tokens for more than one scope.
5608 ///
5609 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5610 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5611 /// sufficient, a read-write scope will do as well.
5612 pub fn add_scope<St>(mut self, scope: St) -> OrganizationBillingAccountListCall<'a, C>
5613 where
5614 St: AsRef<str>,
5615 {
5616 self._scopes.insert(String::from(scope.as_ref()));
5617 self
5618 }
5619 /// Identifies the authorization scope(s) for the method you are building.
5620 ///
5621 /// See [`Self::add_scope()`] for details.
5622 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationBillingAccountListCall<'a, C>
5623 where
5624 I: IntoIterator<Item = St>,
5625 St: AsRef<str>,
5626 {
5627 self._scopes
5628 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5629 self
5630 }
5631
5632 /// Removes all scopes, and no default scope will be used either.
5633 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5634 /// for details).
5635 pub fn clear_scopes(mut self) -> OrganizationBillingAccountListCall<'a, C> {
5636 self._scopes.clear();
5637 self
5638 }
5639}
5640
5641/// Changes which parent organization a billing account belongs to.
5642///
5643/// A builder for the *billingAccounts.move* method supported by a *organization* resource.
5644/// It is not used directly, but through a [`OrganizationMethods`] instance.
5645///
5646/// # Example
5647///
5648/// Instantiate a resource method builder
5649///
5650/// ```test_harness,no_run
5651/// # extern crate hyper;
5652/// # extern crate hyper_rustls;
5653/// # extern crate google_cloudbilling1 as cloudbilling1;
5654/// # async fn dox() {
5655/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5656///
5657/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5658/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5659/// # .with_native_roots()
5660/// # .unwrap()
5661/// # .https_only()
5662/// # .enable_http2()
5663/// # .build();
5664///
5665/// # let executor = hyper_util::rt::TokioExecutor::new();
5666/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5667/// # secret,
5668/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5669/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5670/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5671/// # ),
5672/// # ).build().await.unwrap();
5673///
5674/// # let client = hyper_util::client::legacy::Client::builder(
5675/// # hyper_util::rt::TokioExecutor::new()
5676/// # )
5677/// # .build(
5678/// # hyper_rustls::HttpsConnectorBuilder::new()
5679/// # .with_native_roots()
5680/// # .unwrap()
5681/// # .https_or_http()
5682/// # .enable_http2()
5683/// # .build()
5684/// # );
5685/// # let mut hub = Cloudbilling::new(client, auth);
5686/// // You can configure optional parameters by calling the respective setters at will, and
5687/// // execute the final call using `doit()`.
5688/// // Values shown here are possibly random and not representative !
5689/// let result = hub.organizations().billing_accounts_move("destinationParent", "name")
5690/// .doit().await;
5691/// # }
5692/// ```
5693pub struct OrganizationBillingAccountMoveCall<'a, C>
5694where
5695 C: 'a,
5696{
5697 hub: &'a Cloudbilling<C>,
5698 _destination_parent: String,
5699 _name: String,
5700 _delegate: Option<&'a mut dyn common::Delegate>,
5701 _additional_params: HashMap<String, String>,
5702 _scopes: BTreeSet<String>,
5703}
5704
5705impl<'a, C> common::CallBuilder for OrganizationBillingAccountMoveCall<'a, C> {}
5706
5707impl<'a, C> OrganizationBillingAccountMoveCall<'a, C>
5708where
5709 C: common::Connector,
5710{
5711 /// Perform the operation you have build so far.
5712 pub async fn doit(mut self) -> common::Result<(common::Response, BillingAccount)> {
5713 use std::borrow::Cow;
5714 use std::io::{Read, Seek};
5715
5716 use common::{url::Params, ToParts};
5717 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5718
5719 let mut dd = common::DefaultDelegate;
5720 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5721 dlg.begin(common::MethodInfo {
5722 id: "cloudbilling.organizations.billingAccounts.move",
5723 http_method: hyper::Method::GET,
5724 });
5725
5726 for &field in ["alt", "destinationParent", "name"].iter() {
5727 if self._additional_params.contains_key(field) {
5728 dlg.finished(false);
5729 return Err(common::Error::FieldClash(field));
5730 }
5731 }
5732
5733 let mut params = Params::with_capacity(4 + self._additional_params.len());
5734 params.push("destinationParent", self._destination_parent);
5735 params.push("name", self._name);
5736
5737 params.extend(self._additional_params.iter());
5738
5739 params.push("alt", "json");
5740 let mut url = self.hub._base_url.clone() + "v1/{+destinationParent}/{+name}:move";
5741 if self._scopes.is_empty() {
5742 self._scopes
5743 .insert(Scope::CloudPlatform.as_ref().to_string());
5744 }
5745
5746 #[allow(clippy::single_element_loop)]
5747 for &(find_this, param_name) in [
5748 ("{+destinationParent}", "destinationParent"),
5749 ("{+name}", "name"),
5750 ]
5751 .iter()
5752 {
5753 url = params.uri_replacement(url, param_name, find_this, true);
5754 }
5755 {
5756 let to_remove = ["name", "destinationParent"];
5757 params.remove_params(&to_remove);
5758 }
5759
5760 let url = params.parse_with_url(&url);
5761
5762 loop {
5763 let token = match self
5764 .hub
5765 .auth
5766 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5767 .await
5768 {
5769 Ok(token) => token,
5770 Err(e) => match dlg.token(e) {
5771 Ok(token) => token,
5772 Err(e) => {
5773 dlg.finished(false);
5774 return Err(common::Error::MissingToken(e));
5775 }
5776 },
5777 };
5778 let mut req_result = {
5779 let client = &self.hub.client;
5780 dlg.pre_request();
5781 let mut req_builder = hyper::Request::builder()
5782 .method(hyper::Method::GET)
5783 .uri(url.as_str())
5784 .header(USER_AGENT, self.hub._user_agent.clone());
5785
5786 if let Some(token) = token.as_ref() {
5787 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5788 }
5789
5790 let request = req_builder
5791 .header(CONTENT_LENGTH, 0_u64)
5792 .body(common::to_body::<String>(None));
5793
5794 client.request(request.unwrap()).await
5795 };
5796
5797 match req_result {
5798 Err(err) => {
5799 if let common::Retry::After(d) = dlg.http_error(&err) {
5800 sleep(d).await;
5801 continue;
5802 }
5803 dlg.finished(false);
5804 return Err(common::Error::HttpError(err));
5805 }
5806 Ok(res) => {
5807 let (mut parts, body) = res.into_parts();
5808 let mut body = common::Body::new(body);
5809 if !parts.status.is_success() {
5810 let bytes = common::to_bytes(body).await.unwrap_or_default();
5811 let error = serde_json::from_str(&common::to_string(&bytes));
5812 let response = common::to_response(parts, bytes.into());
5813
5814 if let common::Retry::After(d) =
5815 dlg.http_failure(&response, error.as_ref().ok())
5816 {
5817 sleep(d).await;
5818 continue;
5819 }
5820
5821 dlg.finished(false);
5822
5823 return Err(match error {
5824 Ok(value) => common::Error::BadRequest(value),
5825 _ => common::Error::Failure(response),
5826 });
5827 }
5828 let response = {
5829 let bytes = common::to_bytes(body).await.unwrap_or_default();
5830 let encoded = common::to_string(&bytes);
5831 match serde_json::from_str(&encoded) {
5832 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5833 Err(error) => {
5834 dlg.response_json_decode_error(&encoded, &error);
5835 return Err(common::Error::JsonDecodeError(
5836 encoded.to_string(),
5837 error,
5838 ));
5839 }
5840 }
5841 };
5842
5843 dlg.finished(true);
5844 return Ok(response);
5845 }
5846 }
5847 }
5848 }
5849
5850 /// Required. The resource name of the Organization to move the billing account under. Must be of the form `organizations/{organization_id}`.
5851 ///
5852 /// Sets the *destination parent* path property to the given value.
5853 ///
5854 /// Even though the property as already been set when instantiating this call,
5855 /// we provide this method for API completeness.
5856 pub fn destination_parent(
5857 mut self,
5858 new_value: &str,
5859 ) -> OrganizationBillingAccountMoveCall<'a, C> {
5860 self._destination_parent = new_value.to_string();
5861 self
5862 }
5863 /// Required. The resource name of the billing account to move. Must be of the form `billingAccounts/{billing_account_id}`. The specified billing account cannot be a subaccount, since a subaccount always belongs to the same organization as its parent account.
5864 ///
5865 /// Sets the *name* path property to the given value.
5866 ///
5867 /// Even though the property as already been set when instantiating this call,
5868 /// we provide this method for API completeness.
5869 pub fn name(mut self, new_value: &str) -> OrganizationBillingAccountMoveCall<'a, C> {
5870 self._name = new_value.to_string();
5871 self
5872 }
5873 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5874 /// while executing the actual API request.
5875 ///
5876 /// ````text
5877 /// It should be used to handle progress information, and to implement a certain level of resilience.
5878 /// ````
5879 ///
5880 /// Sets the *delegate* property to the given value.
5881 pub fn delegate(
5882 mut self,
5883 new_value: &'a mut dyn common::Delegate,
5884 ) -> OrganizationBillingAccountMoveCall<'a, C> {
5885 self._delegate = Some(new_value);
5886 self
5887 }
5888
5889 /// Set any additional parameter of the query string used in the request.
5890 /// It should be used to set parameters which are not yet available through their own
5891 /// setters.
5892 ///
5893 /// Please note that this method must not be used to set any of the known parameters
5894 /// which have their own setter method. If done anyway, the request will fail.
5895 ///
5896 /// # Additional Parameters
5897 ///
5898 /// * *$.xgafv* (query-string) - V1 error format.
5899 /// * *access_token* (query-string) - OAuth access token.
5900 /// * *alt* (query-string) - Data format for response.
5901 /// * *callback* (query-string) - JSONP
5902 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5903 /// * *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.
5904 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5905 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5906 /// * *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.
5907 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5908 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5909 pub fn param<T>(mut self, name: T, value: T) -> OrganizationBillingAccountMoveCall<'a, C>
5910 where
5911 T: AsRef<str>,
5912 {
5913 self._additional_params
5914 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5915 self
5916 }
5917
5918 /// Identifies the authorization scope for the method you are building.
5919 ///
5920 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5921 /// [`Scope::CloudPlatform`].
5922 ///
5923 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5924 /// tokens for more than one scope.
5925 ///
5926 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5927 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5928 /// sufficient, a read-write scope will do as well.
5929 pub fn add_scope<St>(mut self, scope: St) -> OrganizationBillingAccountMoveCall<'a, C>
5930 where
5931 St: AsRef<str>,
5932 {
5933 self._scopes.insert(String::from(scope.as_ref()));
5934 self
5935 }
5936 /// Identifies the authorization scope(s) for the method you are building.
5937 ///
5938 /// See [`Self::add_scope()`] for details.
5939 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationBillingAccountMoveCall<'a, C>
5940 where
5941 I: IntoIterator<Item = St>,
5942 St: AsRef<str>,
5943 {
5944 self._scopes
5945 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5946 self
5947 }
5948
5949 /// Removes all scopes, and no default scope will be used either.
5950 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5951 /// for details).
5952 pub fn clear_scopes(mut self) -> OrganizationBillingAccountMoveCall<'a, C> {
5953 self._scopes.clear();
5954 self
5955 }
5956}
5957
5958/// Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.
5959///
5960/// A builder for the *getBillingInfo* method supported by a *project* resource.
5961/// It is not used directly, but through a [`ProjectMethods`] instance.
5962///
5963/// # Example
5964///
5965/// Instantiate a resource method builder
5966///
5967/// ```test_harness,no_run
5968/// # extern crate hyper;
5969/// # extern crate hyper_rustls;
5970/// # extern crate google_cloudbilling1 as cloudbilling1;
5971/// # async fn dox() {
5972/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5973///
5974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5975/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5976/// # .with_native_roots()
5977/// # .unwrap()
5978/// # .https_only()
5979/// # .enable_http2()
5980/// # .build();
5981///
5982/// # let executor = hyper_util::rt::TokioExecutor::new();
5983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5984/// # secret,
5985/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5986/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5987/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5988/// # ),
5989/// # ).build().await.unwrap();
5990///
5991/// # let client = hyper_util::client::legacy::Client::builder(
5992/// # hyper_util::rt::TokioExecutor::new()
5993/// # )
5994/// # .build(
5995/// # hyper_rustls::HttpsConnectorBuilder::new()
5996/// # .with_native_roots()
5997/// # .unwrap()
5998/// # .https_or_http()
5999/// # .enable_http2()
6000/// # .build()
6001/// # );
6002/// # let mut hub = Cloudbilling::new(client, auth);
6003/// // You can configure optional parameters by calling the respective setters at will, and
6004/// // execute the final call using `doit()`.
6005/// // Values shown here are possibly random and not representative !
6006/// let result = hub.projects().get_billing_info("name")
6007/// .doit().await;
6008/// # }
6009/// ```
6010pub struct ProjectGetBillingInfoCall<'a, C>
6011where
6012 C: 'a,
6013{
6014 hub: &'a Cloudbilling<C>,
6015 _name: String,
6016 _delegate: Option<&'a mut dyn common::Delegate>,
6017 _additional_params: HashMap<String, String>,
6018 _scopes: BTreeSet<String>,
6019}
6020
6021impl<'a, C> common::CallBuilder for ProjectGetBillingInfoCall<'a, C> {}
6022
6023impl<'a, C> ProjectGetBillingInfoCall<'a, C>
6024where
6025 C: common::Connector,
6026{
6027 /// Perform the operation you have build so far.
6028 pub async fn doit(mut self) -> common::Result<(common::Response, ProjectBillingInfo)> {
6029 use std::borrow::Cow;
6030 use std::io::{Read, Seek};
6031
6032 use common::{url::Params, ToParts};
6033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6034
6035 let mut dd = common::DefaultDelegate;
6036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6037 dlg.begin(common::MethodInfo {
6038 id: "cloudbilling.projects.getBillingInfo",
6039 http_method: hyper::Method::GET,
6040 });
6041
6042 for &field in ["alt", "name"].iter() {
6043 if self._additional_params.contains_key(field) {
6044 dlg.finished(false);
6045 return Err(common::Error::FieldClash(field));
6046 }
6047 }
6048
6049 let mut params = Params::with_capacity(3 + self._additional_params.len());
6050 params.push("name", self._name);
6051
6052 params.extend(self._additional_params.iter());
6053
6054 params.push("alt", "json");
6055 let mut url = self.hub._base_url.clone() + "v1/{+name}/billingInfo";
6056 if self._scopes.is_empty() {
6057 self._scopes
6058 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
6059 }
6060
6061 #[allow(clippy::single_element_loop)]
6062 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6063 url = params.uri_replacement(url, param_name, find_this, true);
6064 }
6065 {
6066 let to_remove = ["name"];
6067 params.remove_params(&to_remove);
6068 }
6069
6070 let url = params.parse_with_url(&url);
6071
6072 loop {
6073 let token = match self
6074 .hub
6075 .auth
6076 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6077 .await
6078 {
6079 Ok(token) => token,
6080 Err(e) => match dlg.token(e) {
6081 Ok(token) => token,
6082 Err(e) => {
6083 dlg.finished(false);
6084 return Err(common::Error::MissingToken(e));
6085 }
6086 },
6087 };
6088 let mut req_result = {
6089 let client = &self.hub.client;
6090 dlg.pre_request();
6091 let mut req_builder = hyper::Request::builder()
6092 .method(hyper::Method::GET)
6093 .uri(url.as_str())
6094 .header(USER_AGENT, self.hub._user_agent.clone());
6095
6096 if let Some(token) = token.as_ref() {
6097 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6098 }
6099
6100 let request = req_builder
6101 .header(CONTENT_LENGTH, 0_u64)
6102 .body(common::to_body::<String>(None));
6103
6104 client.request(request.unwrap()).await
6105 };
6106
6107 match req_result {
6108 Err(err) => {
6109 if let common::Retry::After(d) = dlg.http_error(&err) {
6110 sleep(d).await;
6111 continue;
6112 }
6113 dlg.finished(false);
6114 return Err(common::Error::HttpError(err));
6115 }
6116 Ok(res) => {
6117 let (mut parts, body) = res.into_parts();
6118 let mut body = common::Body::new(body);
6119 if !parts.status.is_success() {
6120 let bytes = common::to_bytes(body).await.unwrap_or_default();
6121 let error = serde_json::from_str(&common::to_string(&bytes));
6122 let response = common::to_response(parts, bytes.into());
6123
6124 if let common::Retry::After(d) =
6125 dlg.http_failure(&response, error.as_ref().ok())
6126 {
6127 sleep(d).await;
6128 continue;
6129 }
6130
6131 dlg.finished(false);
6132
6133 return Err(match error {
6134 Ok(value) => common::Error::BadRequest(value),
6135 _ => common::Error::Failure(response),
6136 });
6137 }
6138 let response = {
6139 let bytes = common::to_bytes(body).await.unwrap_or_default();
6140 let encoded = common::to_string(&bytes);
6141 match serde_json::from_str(&encoded) {
6142 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6143 Err(error) => {
6144 dlg.response_json_decode_error(&encoded, &error);
6145 return Err(common::Error::JsonDecodeError(
6146 encoded.to_string(),
6147 error,
6148 ));
6149 }
6150 }
6151 };
6152
6153 dlg.finished(true);
6154 return Ok(response);
6155 }
6156 }
6157 }
6158 }
6159
6160 /// Required. The resource name of the project for which billing information is retrieved. For example, `projects/tokyo-rain-123`.
6161 ///
6162 /// Sets the *name* path property to the given value.
6163 ///
6164 /// Even though the property as already been set when instantiating this call,
6165 /// we provide this method for API completeness.
6166 pub fn name(mut self, new_value: &str) -> ProjectGetBillingInfoCall<'a, C> {
6167 self._name = new_value.to_string();
6168 self
6169 }
6170 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6171 /// while executing the actual API request.
6172 ///
6173 /// ````text
6174 /// It should be used to handle progress information, and to implement a certain level of resilience.
6175 /// ````
6176 ///
6177 /// Sets the *delegate* property to the given value.
6178 pub fn delegate(
6179 mut self,
6180 new_value: &'a mut dyn common::Delegate,
6181 ) -> ProjectGetBillingInfoCall<'a, C> {
6182 self._delegate = Some(new_value);
6183 self
6184 }
6185
6186 /// Set any additional parameter of the query string used in the request.
6187 /// It should be used to set parameters which are not yet available through their own
6188 /// setters.
6189 ///
6190 /// Please note that this method must not be used to set any of the known parameters
6191 /// which have their own setter method. If done anyway, the request will fail.
6192 ///
6193 /// # Additional Parameters
6194 ///
6195 /// * *$.xgafv* (query-string) - V1 error format.
6196 /// * *access_token* (query-string) - OAuth access token.
6197 /// * *alt* (query-string) - Data format for response.
6198 /// * *callback* (query-string) - JSONP
6199 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6200 /// * *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.
6201 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6202 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6203 /// * *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.
6204 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6205 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6206 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetBillingInfoCall<'a, C>
6207 where
6208 T: AsRef<str>,
6209 {
6210 self._additional_params
6211 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6212 self
6213 }
6214
6215 /// Identifies the authorization scope for the method you are building.
6216 ///
6217 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6218 /// [`Scope::CloudBillingReadonly`].
6219 ///
6220 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6221 /// tokens for more than one scope.
6222 ///
6223 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6224 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6225 /// sufficient, a read-write scope will do as well.
6226 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetBillingInfoCall<'a, C>
6227 where
6228 St: AsRef<str>,
6229 {
6230 self._scopes.insert(String::from(scope.as_ref()));
6231 self
6232 }
6233 /// Identifies the authorization scope(s) for the method you are building.
6234 ///
6235 /// See [`Self::add_scope()`] for details.
6236 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetBillingInfoCall<'a, C>
6237 where
6238 I: IntoIterator<Item = St>,
6239 St: AsRef<str>,
6240 {
6241 self._scopes
6242 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6243 self
6244 }
6245
6246 /// Removes all scopes, and no default scope will be used either.
6247 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6248 /// for details).
6249 pub fn clear_scopes(mut self) -> ProjectGetBillingInfoCall<'a, C> {
6250 self._scopes.clear();
6251 self
6252 }
6253}
6254
6255/// Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.
6256///
6257/// A builder for the *updateBillingInfo* method supported by a *project* resource.
6258/// It is not used directly, but through a [`ProjectMethods`] instance.
6259///
6260/// # Example
6261///
6262/// Instantiate a resource method builder
6263///
6264/// ```test_harness,no_run
6265/// # extern crate hyper;
6266/// # extern crate hyper_rustls;
6267/// # extern crate google_cloudbilling1 as cloudbilling1;
6268/// use cloudbilling1::api::ProjectBillingInfo;
6269/// # async fn dox() {
6270/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6271///
6272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6274/// # .with_native_roots()
6275/// # .unwrap()
6276/// # .https_only()
6277/// # .enable_http2()
6278/// # .build();
6279///
6280/// # let executor = hyper_util::rt::TokioExecutor::new();
6281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6282/// # secret,
6283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6284/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6285/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6286/// # ),
6287/// # ).build().await.unwrap();
6288///
6289/// # let client = hyper_util::client::legacy::Client::builder(
6290/// # hyper_util::rt::TokioExecutor::new()
6291/// # )
6292/// # .build(
6293/// # hyper_rustls::HttpsConnectorBuilder::new()
6294/// # .with_native_roots()
6295/// # .unwrap()
6296/// # .https_or_http()
6297/// # .enable_http2()
6298/// # .build()
6299/// # );
6300/// # let mut hub = Cloudbilling::new(client, auth);
6301/// // As the method needs a request, you would usually fill it with the desired information
6302/// // into the respective structure. Some of the parts shown here might not be applicable !
6303/// // Values shown here are possibly random and not representative !
6304/// let mut req = ProjectBillingInfo::default();
6305///
6306/// // You can configure optional parameters by calling the respective setters at will, and
6307/// // execute the final call using `doit()`.
6308/// // Values shown here are possibly random and not representative !
6309/// let result = hub.projects().update_billing_info(req, "name")
6310/// .doit().await;
6311/// # }
6312/// ```
6313pub struct ProjectUpdateBillingInfoCall<'a, C>
6314where
6315 C: 'a,
6316{
6317 hub: &'a Cloudbilling<C>,
6318 _request: ProjectBillingInfo,
6319 _name: String,
6320 _delegate: Option<&'a mut dyn common::Delegate>,
6321 _additional_params: HashMap<String, String>,
6322 _scopes: BTreeSet<String>,
6323}
6324
6325impl<'a, C> common::CallBuilder for ProjectUpdateBillingInfoCall<'a, C> {}
6326
6327impl<'a, C> ProjectUpdateBillingInfoCall<'a, C>
6328where
6329 C: common::Connector,
6330{
6331 /// Perform the operation you have build so far.
6332 pub async fn doit(mut self) -> common::Result<(common::Response, ProjectBillingInfo)> {
6333 use std::borrow::Cow;
6334 use std::io::{Read, Seek};
6335
6336 use common::{url::Params, ToParts};
6337 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6338
6339 let mut dd = common::DefaultDelegate;
6340 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6341 dlg.begin(common::MethodInfo {
6342 id: "cloudbilling.projects.updateBillingInfo",
6343 http_method: hyper::Method::PUT,
6344 });
6345
6346 for &field in ["alt", "name"].iter() {
6347 if self._additional_params.contains_key(field) {
6348 dlg.finished(false);
6349 return Err(common::Error::FieldClash(field));
6350 }
6351 }
6352
6353 let mut params = Params::with_capacity(4 + self._additional_params.len());
6354 params.push("name", self._name);
6355
6356 params.extend(self._additional_params.iter());
6357
6358 params.push("alt", "json");
6359 let mut url = self.hub._base_url.clone() + "v1/{+name}/billingInfo";
6360 if self._scopes.is_empty() {
6361 self._scopes
6362 .insert(Scope::CloudPlatform.as_ref().to_string());
6363 }
6364
6365 #[allow(clippy::single_element_loop)]
6366 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6367 url = params.uri_replacement(url, param_name, find_this, true);
6368 }
6369 {
6370 let to_remove = ["name"];
6371 params.remove_params(&to_remove);
6372 }
6373
6374 let url = params.parse_with_url(&url);
6375
6376 let mut json_mime_type = mime::APPLICATION_JSON;
6377 let mut request_value_reader = {
6378 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6379 common::remove_json_null_values(&mut value);
6380 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6381 serde_json::to_writer(&mut dst, &value).unwrap();
6382 dst
6383 };
6384 let request_size = request_value_reader
6385 .seek(std::io::SeekFrom::End(0))
6386 .unwrap();
6387 request_value_reader
6388 .seek(std::io::SeekFrom::Start(0))
6389 .unwrap();
6390
6391 loop {
6392 let token = match self
6393 .hub
6394 .auth
6395 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6396 .await
6397 {
6398 Ok(token) => token,
6399 Err(e) => match dlg.token(e) {
6400 Ok(token) => token,
6401 Err(e) => {
6402 dlg.finished(false);
6403 return Err(common::Error::MissingToken(e));
6404 }
6405 },
6406 };
6407 request_value_reader
6408 .seek(std::io::SeekFrom::Start(0))
6409 .unwrap();
6410 let mut req_result = {
6411 let client = &self.hub.client;
6412 dlg.pre_request();
6413 let mut req_builder = hyper::Request::builder()
6414 .method(hyper::Method::PUT)
6415 .uri(url.as_str())
6416 .header(USER_AGENT, self.hub._user_agent.clone());
6417
6418 if let Some(token) = token.as_ref() {
6419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6420 }
6421
6422 let request = req_builder
6423 .header(CONTENT_TYPE, json_mime_type.to_string())
6424 .header(CONTENT_LENGTH, request_size as u64)
6425 .body(common::to_body(
6426 request_value_reader.get_ref().clone().into(),
6427 ));
6428
6429 client.request(request.unwrap()).await
6430 };
6431
6432 match req_result {
6433 Err(err) => {
6434 if let common::Retry::After(d) = dlg.http_error(&err) {
6435 sleep(d).await;
6436 continue;
6437 }
6438 dlg.finished(false);
6439 return Err(common::Error::HttpError(err));
6440 }
6441 Ok(res) => {
6442 let (mut parts, body) = res.into_parts();
6443 let mut body = common::Body::new(body);
6444 if !parts.status.is_success() {
6445 let bytes = common::to_bytes(body).await.unwrap_or_default();
6446 let error = serde_json::from_str(&common::to_string(&bytes));
6447 let response = common::to_response(parts, bytes.into());
6448
6449 if let common::Retry::After(d) =
6450 dlg.http_failure(&response, error.as_ref().ok())
6451 {
6452 sleep(d).await;
6453 continue;
6454 }
6455
6456 dlg.finished(false);
6457
6458 return Err(match error {
6459 Ok(value) => common::Error::BadRequest(value),
6460 _ => common::Error::Failure(response),
6461 });
6462 }
6463 let response = {
6464 let bytes = common::to_bytes(body).await.unwrap_or_default();
6465 let encoded = common::to_string(&bytes);
6466 match serde_json::from_str(&encoded) {
6467 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6468 Err(error) => {
6469 dlg.response_json_decode_error(&encoded, &error);
6470 return Err(common::Error::JsonDecodeError(
6471 encoded.to_string(),
6472 error,
6473 ));
6474 }
6475 }
6476 };
6477
6478 dlg.finished(true);
6479 return Ok(response);
6480 }
6481 }
6482 }
6483 }
6484
6485 ///
6486 /// Sets the *request* property to the given value.
6487 ///
6488 /// Even though the property as already been set when instantiating this call,
6489 /// we provide this method for API completeness.
6490 pub fn request(mut self, new_value: ProjectBillingInfo) -> ProjectUpdateBillingInfoCall<'a, C> {
6491 self._request = new_value;
6492 self
6493 }
6494 /// Required. The resource name of the project associated with the billing information that you want to update. For example, `projects/tokyo-rain-123`.
6495 ///
6496 /// Sets the *name* path property to the given value.
6497 ///
6498 /// Even though the property as already been set when instantiating this call,
6499 /// we provide this method for API completeness.
6500 pub fn name(mut self, new_value: &str) -> ProjectUpdateBillingInfoCall<'a, C> {
6501 self._name = new_value.to_string();
6502 self
6503 }
6504 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6505 /// while executing the actual API request.
6506 ///
6507 /// ````text
6508 /// It should be used to handle progress information, and to implement a certain level of resilience.
6509 /// ````
6510 ///
6511 /// Sets the *delegate* property to the given value.
6512 pub fn delegate(
6513 mut self,
6514 new_value: &'a mut dyn common::Delegate,
6515 ) -> ProjectUpdateBillingInfoCall<'a, C> {
6516 self._delegate = Some(new_value);
6517 self
6518 }
6519
6520 /// Set any additional parameter of the query string used in the request.
6521 /// It should be used to set parameters which are not yet available through their own
6522 /// setters.
6523 ///
6524 /// Please note that this method must not be used to set any of the known parameters
6525 /// which have their own setter method. If done anyway, the request will fail.
6526 ///
6527 /// # Additional Parameters
6528 ///
6529 /// * *$.xgafv* (query-string) - V1 error format.
6530 /// * *access_token* (query-string) - OAuth access token.
6531 /// * *alt* (query-string) - Data format for response.
6532 /// * *callback* (query-string) - JSONP
6533 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6534 /// * *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.
6535 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6536 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6537 /// * *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.
6538 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6539 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6540 pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateBillingInfoCall<'a, C>
6541 where
6542 T: AsRef<str>,
6543 {
6544 self._additional_params
6545 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6546 self
6547 }
6548
6549 /// Identifies the authorization scope for the method you are building.
6550 ///
6551 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6552 /// [`Scope::CloudPlatform`].
6553 ///
6554 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6555 /// tokens for more than one scope.
6556 ///
6557 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6558 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6559 /// sufficient, a read-write scope will do as well.
6560 pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateBillingInfoCall<'a, C>
6561 where
6562 St: AsRef<str>,
6563 {
6564 self._scopes.insert(String::from(scope.as_ref()));
6565 self
6566 }
6567 /// Identifies the authorization scope(s) for the method you are building.
6568 ///
6569 /// See [`Self::add_scope()`] for details.
6570 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateBillingInfoCall<'a, C>
6571 where
6572 I: IntoIterator<Item = St>,
6573 St: AsRef<str>,
6574 {
6575 self._scopes
6576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6577 self
6578 }
6579
6580 /// Removes all scopes, and no default scope will be used either.
6581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6582 /// for details).
6583 pub fn clear_scopes(mut self) -> ProjectUpdateBillingInfoCall<'a, C> {
6584 self._scopes.clear();
6585 self
6586 }
6587}
6588
6589/// Lists all publicly available SKUs for a given cloud service.
6590///
6591/// A builder for the *skus.list* method supported by a *service* resource.
6592/// It is not used directly, but through a [`ServiceMethods`] instance.
6593///
6594/// # Example
6595///
6596/// Instantiate a resource method builder
6597///
6598/// ```test_harness,no_run
6599/// # extern crate hyper;
6600/// # extern crate hyper_rustls;
6601/// # extern crate google_cloudbilling1 as cloudbilling1;
6602/// # async fn dox() {
6603/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6604///
6605/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6606/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6607/// # .with_native_roots()
6608/// # .unwrap()
6609/// # .https_only()
6610/// # .enable_http2()
6611/// # .build();
6612///
6613/// # let executor = hyper_util::rt::TokioExecutor::new();
6614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6615/// # secret,
6616/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6617/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6618/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6619/// # ),
6620/// # ).build().await.unwrap();
6621///
6622/// # let client = hyper_util::client::legacy::Client::builder(
6623/// # hyper_util::rt::TokioExecutor::new()
6624/// # )
6625/// # .build(
6626/// # hyper_rustls::HttpsConnectorBuilder::new()
6627/// # .with_native_roots()
6628/// # .unwrap()
6629/// # .https_or_http()
6630/// # .enable_http2()
6631/// # .build()
6632/// # );
6633/// # let mut hub = Cloudbilling::new(client, auth);
6634/// // You can configure optional parameters by calling the respective setters at will, and
6635/// // execute the final call using `doit()`.
6636/// // Values shown here are possibly random and not representative !
6637/// let result = hub.services().skus_list("parent")
6638/// .start_time(chrono::Utc::now())
6639/// .page_token("Stet")
6640/// .page_size(-13)
6641/// .end_time(chrono::Utc::now())
6642/// .currency_code("et")
6643/// .doit().await;
6644/// # }
6645/// ```
6646pub struct ServiceSkuListCall<'a, C>
6647where
6648 C: 'a,
6649{
6650 hub: &'a Cloudbilling<C>,
6651 _parent: String,
6652 _start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
6653 _page_token: Option<String>,
6654 _page_size: Option<i32>,
6655 _end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
6656 _currency_code: Option<String>,
6657 _delegate: Option<&'a mut dyn common::Delegate>,
6658 _additional_params: HashMap<String, String>,
6659 _scopes: BTreeSet<String>,
6660}
6661
6662impl<'a, C> common::CallBuilder for ServiceSkuListCall<'a, C> {}
6663
6664impl<'a, C> ServiceSkuListCall<'a, C>
6665where
6666 C: common::Connector,
6667{
6668 /// Perform the operation you have build so far.
6669 pub async fn doit(mut self) -> common::Result<(common::Response, ListSkusResponse)> {
6670 use std::borrow::Cow;
6671 use std::io::{Read, Seek};
6672
6673 use common::{url::Params, ToParts};
6674 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6675
6676 let mut dd = common::DefaultDelegate;
6677 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6678 dlg.begin(common::MethodInfo {
6679 id: "cloudbilling.services.skus.list",
6680 http_method: hyper::Method::GET,
6681 });
6682
6683 for &field in [
6684 "alt",
6685 "parent",
6686 "startTime",
6687 "pageToken",
6688 "pageSize",
6689 "endTime",
6690 "currencyCode",
6691 ]
6692 .iter()
6693 {
6694 if self._additional_params.contains_key(field) {
6695 dlg.finished(false);
6696 return Err(common::Error::FieldClash(field));
6697 }
6698 }
6699
6700 let mut params = Params::with_capacity(8 + self._additional_params.len());
6701 params.push("parent", self._parent);
6702 if let Some(value) = self._start_time.as_ref() {
6703 params.push("startTime", common::serde::datetime_to_string(&value));
6704 }
6705 if let Some(value) = self._page_token.as_ref() {
6706 params.push("pageToken", value);
6707 }
6708 if let Some(value) = self._page_size.as_ref() {
6709 params.push("pageSize", value.to_string());
6710 }
6711 if let Some(value) = self._end_time.as_ref() {
6712 params.push("endTime", common::serde::datetime_to_string(&value));
6713 }
6714 if let Some(value) = self._currency_code.as_ref() {
6715 params.push("currencyCode", value);
6716 }
6717
6718 params.extend(self._additional_params.iter());
6719
6720 params.push("alt", "json");
6721 let mut url = self.hub._base_url.clone() + "v1/{+parent}/skus";
6722 if self._scopes.is_empty() {
6723 self._scopes
6724 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
6725 }
6726
6727 #[allow(clippy::single_element_loop)]
6728 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6729 url = params.uri_replacement(url, param_name, find_this, true);
6730 }
6731 {
6732 let to_remove = ["parent"];
6733 params.remove_params(&to_remove);
6734 }
6735
6736 let url = params.parse_with_url(&url);
6737
6738 loop {
6739 let token = match self
6740 .hub
6741 .auth
6742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6743 .await
6744 {
6745 Ok(token) => token,
6746 Err(e) => match dlg.token(e) {
6747 Ok(token) => token,
6748 Err(e) => {
6749 dlg.finished(false);
6750 return Err(common::Error::MissingToken(e));
6751 }
6752 },
6753 };
6754 let mut req_result = {
6755 let client = &self.hub.client;
6756 dlg.pre_request();
6757 let mut req_builder = hyper::Request::builder()
6758 .method(hyper::Method::GET)
6759 .uri(url.as_str())
6760 .header(USER_AGENT, self.hub._user_agent.clone());
6761
6762 if let Some(token) = token.as_ref() {
6763 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6764 }
6765
6766 let request = req_builder
6767 .header(CONTENT_LENGTH, 0_u64)
6768 .body(common::to_body::<String>(None));
6769
6770 client.request(request.unwrap()).await
6771 };
6772
6773 match req_result {
6774 Err(err) => {
6775 if let common::Retry::After(d) = dlg.http_error(&err) {
6776 sleep(d).await;
6777 continue;
6778 }
6779 dlg.finished(false);
6780 return Err(common::Error::HttpError(err));
6781 }
6782 Ok(res) => {
6783 let (mut parts, body) = res.into_parts();
6784 let mut body = common::Body::new(body);
6785 if !parts.status.is_success() {
6786 let bytes = common::to_bytes(body).await.unwrap_or_default();
6787 let error = serde_json::from_str(&common::to_string(&bytes));
6788 let response = common::to_response(parts, bytes.into());
6789
6790 if let common::Retry::After(d) =
6791 dlg.http_failure(&response, error.as_ref().ok())
6792 {
6793 sleep(d).await;
6794 continue;
6795 }
6796
6797 dlg.finished(false);
6798
6799 return Err(match error {
6800 Ok(value) => common::Error::BadRequest(value),
6801 _ => common::Error::Failure(response),
6802 });
6803 }
6804 let response = {
6805 let bytes = common::to_bytes(body).await.unwrap_or_default();
6806 let encoded = common::to_string(&bytes);
6807 match serde_json::from_str(&encoded) {
6808 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6809 Err(error) => {
6810 dlg.response_json_decode_error(&encoded, &error);
6811 return Err(common::Error::JsonDecodeError(
6812 encoded.to_string(),
6813 error,
6814 ));
6815 }
6816 }
6817 };
6818
6819 dlg.finished(true);
6820 return Ok(response);
6821 }
6822 }
6823 }
6824 }
6825
6826 /// Required. The name of the service. Example: "services/6F81-5844-456A"
6827 ///
6828 /// Sets the *parent* path property to the given value.
6829 ///
6830 /// Even though the property as already been set when instantiating this call,
6831 /// we provide this method for API completeness.
6832 pub fn parent(mut self, new_value: &str) -> ServiceSkuListCall<'a, C> {
6833 self._parent = new_value.to_string();
6834 self
6835 }
6836 /// Optional inclusive start time of the time range for which the pricing versions will be returned. Timestamps in the future are not allowed. The time range has to be within a single calendar month in America/Los_Angeles timezone. Time range as a whole is optional. If not specified, the latest pricing will be returned (up to 12 hours old at most).
6837 ///
6838 /// Sets the *start time* query property to the given value.
6839 pub fn start_time(
6840 mut self,
6841 new_value: chrono::DateTime<chrono::offset::Utc>,
6842 ) -> ServiceSkuListCall<'a, C> {
6843 self._start_time = Some(new_value);
6844 self
6845 }
6846 /// A token identifying a page of results to return. This should be a `next_page_token` value returned from a previous `ListSkus` call. If unspecified, the first page of results is returned.
6847 ///
6848 /// Sets the *page token* query property to the given value.
6849 pub fn page_token(mut self, new_value: &str) -> ServiceSkuListCall<'a, C> {
6850 self._page_token = Some(new_value.to_string());
6851 self
6852 }
6853 /// Requested page size. Defaults to 5000.
6854 ///
6855 /// Sets the *page size* query property to the given value.
6856 pub fn page_size(mut self, new_value: i32) -> ServiceSkuListCall<'a, C> {
6857 self._page_size = Some(new_value);
6858 self
6859 }
6860 /// Optional exclusive end time of the time range for which the pricing versions will be returned. Timestamps in the future are not allowed. The time range has to be within a single calendar month in America/Los_Angeles timezone. Time range as a whole is optional. If not specified, the latest pricing will be returned (up to 12 hours old at most).
6861 ///
6862 /// Sets the *end time* query property to the given value.
6863 pub fn end_time(
6864 mut self,
6865 new_value: chrono::DateTime<chrono::offset::Utc>,
6866 ) -> ServiceSkuListCall<'a, C> {
6867 self._end_time = Some(new_value);
6868 self
6869 }
6870 /// The ISO 4217 currency code for the pricing info in the response proto. Will use the conversion rate as of start_time. Optional. If not specified USD will be used.
6871 ///
6872 /// Sets the *currency code* query property to the given value.
6873 pub fn currency_code(mut self, new_value: &str) -> ServiceSkuListCall<'a, C> {
6874 self._currency_code = Some(new_value.to_string());
6875 self
6876 }
6877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6878 /// while executing the actual API request.
6879 ///
6880 /// ````text
6881 /// It should be used to handle progress information, and to implement a certain level of resilience.
6882 /// ````
6883 ///
6884 /// Sets the *delegate* property to the given value.
6885 pub fn delegate(
6886 mut self,
6887 new_value: &'a mut dyn common::Delegate,
6888 ) -> ServiceSkuListCall<'a, C> {
6889 self._delegate = Some(new_value);
6890 self
6891 }
6892
6893 /// Set any additional parameter of the query string used in the request.
6894 /// It should be used to set parameters which are not yet available through their own
6895 /// setters.
6896 ///
6897 /// Please note that this method must not be used to set any of the known parameters
6898 /// which have their own setter method. If done anyway, the request will fail.
6899 ///
6900 /// # Additional Parameters
6901 ///
6902 /// * *$.xgafv* (query-string) - V1 error format.
6903 /// * *access_token* (query-string) - OAuth access token.
6904 /// * *alt* (query-string) - Data format for response.
6905 /// * *callback* (query-string) - JSONP
6906 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6907 /// * *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.
6908 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6909 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6910 /// * *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.
6911 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6912 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6913 pub fn param<T>(mut self, name: T, value: T) -> ServiceSkuListCall<'a, C>
6914 where
6915 T: AsRef<str>,
6916 {
6917 self._additional_params
6918 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6919 self
6920 }
6921
6922 /// Identifies the authorization scope for the method you are building.
6923 ///
6924 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6925 /// [`Scope::CloudBillingReadonly`].
6926 ///
6927 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6928 /// tokens for more than one scope.
6929 ///
6930 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6931 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6932 /// sufficient, a read-write scope will do as well.
6933 pub fn add_scope<St>(mut self, scope: St) -> ServiceSkuListCall<'a, C>
6934 where
6935 St: AsRef<str>,
6936 {
6937 self._scopes.insert(String::from(scope.as_ref()));
6938 self
6939 }
6940 /// Identifies the authorization scope(s) for the method you are building.
6941 ///
6942 /// See [`Self::add_scope()`] for details.
6943 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceSkuListCall<'a, C>
6944 where
6945 I: IntoIterator<Item = St>,
6946 St: AsRef<str>,
6947 {
6948 self._scopes
6949 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6950 self
6951 }
6952
6953 /// Removes all scopes, and no default scope will be used either.
6954 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6955 /// for details).
6956 pub fn clear_scopes(mut self) -> ServiceSkuListCall<'a, C> {
6957 self._scopes.clear();
6958 self
6959 }
6960}
6961
6962/// Lists all public cloud services.
6963///
6964/// A builder for the *list* method supported by a *service* resource.
6965/// It is not used directly, but through a [`ServiceMethods`] instance.
6966///
6967/// # Example
6968///
6969/// Instantiate a resource method builder
6970///
6971/// ```test_harness,no_run
6972/// # extern crate hyper;
6973/// # extern crate hyper_rustls;
6974/// # extern crate google_cloudbilling1 as cloudbilling1;
6975/// # async fn dox() {
6976/// # use cloudbilling1::{Cloudbilling, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6977///
6978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6979/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6980/// # .with_native_roots()
6981/// # .unwrap()
6982/// # .https_only()
6983/// # .enable_http2()
6984/// # .build();
6985///
6986/// # let executor = hyper_util::rt::TokioExecutor::new();
6987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6988/// # secret,
6989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6990/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6991/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6992/// # ),
6993/// # ).build().await.unwrap();
6994///
6995/// # let client = hyper_util::client::legacy::Client::builder(
6996/// # hyper_util::rt::TokioExecutor::new()
6997/// # )
6998/// # .build(
6999/// # hyper_rustls::HttpsConnectorBuilder::new()
7000/// # .with_native_roots()
7001/// # .unwrap()
7002/// # .https_or_http()
7003/// # .enable_http2()
7004/// # .build()
7005/// # );
7006/// # let mut hub = Cloudbilling::new(client, auth);
7007/// // You can configure optional parameters by calling the respective setters at will, and
7008/// // execute the final call using `doit()`.
7009/// // Values shown here are possibly random and not representative !
7010/// let result = hub.services().list()
7011/// .page_token("sed")
7012/// .page_size(-24)
7013/// .doit().await;
7014/// # }
7015/// ```
7016pub struct ServiceListCall<'a, C>
7017where
7018 C: 'a,
7019{
7020 hub: &'a Cloudbilling<C>,
7021 _page_token: Option<String>,
7022 _page_size: Option<i32>,
7023 _delegate: Option<&'a mut dyn common::Delegate>,
7024 _additional_params: HashMap<String, String>,
7025 _scopes: BTreeSet<String>,
7026}
7027
7028impl<'a, C> common::CallBuilder for ServiceListCall<'a, C> {}
7029
7030impl<'a, C> ServiceListCall<'a, C>
7031where
7032 C: common::Connector,
7033{
7034 /// Perform the operation you have build so far.
7035 pub async fn doit(mut self) -> common::Result<(common::Response, ListServicesResponse)> {
7036 use std::borrow::Cow;
7037 use std::io::{Read, Seek};
7038
7039 use common::{url::Params, ToParts};
7040 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7041
7042 let mut dd = common::DefaultDelegate;
7043 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7044 dlg.begin(common::MethodInfo {
7045 id: "cloudbilling.services.list",
7046 http_method: hyper::Method::GET,
7047 });
7048
7049 for &field in ["alt", "pageToken", "pageSize"].iter() {
7050 if self._additional_params.contains_key(field) {
7051 dlg.finished(false);
7052 return Err(common::Error::FieldClash(field));
7053 }
7054 }
7055
7056 let mut params = Params::with_capacity(4 + self._additional_params.len());
7057 if let Some(value) = self._page_token.as_ref() {
7058 params.push("pageToken", value);
7059 }
7060 if let Some(value) = self._page_size.as_ref() {
7061 params.push("pageSize", value.to_string());
7062 }
7063
7064 params.extend(self._additional_params.iter());
7065
7066 params.push("alt", "json");
7067 let mut url = self.hub._base_url.clone() + "v1/services";
7068 if self._scopes.is_empty() {
7069 self._scopes
7070 .insert(Scope::CloudBillingReadonly.as_ref().to_string());
7071 }
7072
7073 let url = params.parse_with_url(&url);
7074
7075 loop {
7076 let token = match self
7077 .hub
7078 .auth
7079 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7080 .await
7081 {
7082 Ok(token) => token,
7083 Err(e) => match dlg.token(e) {
7084 Ok(token) => token,
7085 Err(e) => {
7086 dlg.finished(false);
7087 return Err(common::Error::MissingToken(e));
7088 }
7089 },
7090 };
7091 let mut req_result = {
7092 let client = &self.hub.client;
7093 dlg.pre_request();
7094 let mut req_builder = hyper::Request::builder()
7095 .method(hyper::Method::GET)
7096 .uri(url.as_str())
7097 .header(USER_AGENT, self.hub._user_agent.clone());
7098
7099 if let Some(token) = token.as_ref() {
7100 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7101 }
7102
7103 let request = req_builder
7104 .header(CONTENT_LENGTH, 0_u64)
7105 .body(common::to_body::<String>(None));
7106
7107 client.request(request.unwrap()).await
7108 };
7109
7110 match req_result {
7111 Err(err) => {
7112 if let common::Retry::After(d) = dlg.http_error(&err) {
7113 sleep(d).await;
7114 continue;
7115 }
7116 dlg.finished(false);
7117 return Err(common::Error::HttpError(err));
7118 }
7119 Ok(res) => {
7120 let (mut parts, body) = res.into_parts();
7121 let mut body = common::Body::new(body);
7122 if !parts.status.is_success() {
7123 let bytes = common::to_bytes(body).await.unwrap_or_default();
7124 let error = serde_json::from_str(&common::to_string(&bytes));
7125 let response = common::to_response(parts, bytes.into());
7126
7127 if let common::Retry::After(d) =
7128 dlg.http_failure(&response, error.as_ref().ok())
7129 {
7130 sleep(d).await;
7131 continue;
7132 }
7133
7134 dlg.finished(false);
7135
7136 return Err(match error {
7137 Ok(value) => common::Error::BadRequest(value),
7138 _ => common::Error::Failure(response),
7139 });
7140 }
7141 let response = {
7142 let bytes = common::to_bytes(body).await.unwrap_or_default();
7143 let encoded = common::to_string(&bytes);
7144 match serde_json::from_str(&encoded) {
7145 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7146 Err(error) => {
7147 dlg.response_json_decode_error(&encoded, &error);
7148 return Err(common::Error::JsonDecodeError(
7149 encoded.to_string(),
7150 error,
7151 ));
7152 }
7153 }
7154 };
7155
7156 dlg.finished(true);
7157 return Ok(response);
7158 }
7159 }
7160 }
7161 }
7162
7163 /// A token identifying a page of results to return. This should be a `next_page_token` value returned from a previous `ListServices` call. If unspecified, the first page of results is returned.
7164 ///
7165 /// Sets the *page token* query property to the given value.
7166 pub fn page_token(mut self, new_value: &str) -> ServiceListCall<'a, C> {
7167 self._page_token = Some(new_value.to_string());
7168 self
7169 }
7170 /// Requested page size. Defaults to 5000.
7171 ///
7172 /// Sets the *page size* query property to the given value.
7173 pub fn page_size(mut self, new_value: i32) -> ServiceListCall<'a, C> {
7174 self._page_size = Some(new_value);
7175 self
7176 }
7177 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7178 /// while executing the actual API request.
7179 ///
7180 /// ````text
7181 /// It should be used to handle progress information, and to implement a certain level of resilience.
7182 /// ````
7183 ///
7184 /// Sets the *delegate* property to the given value.
7185 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceListCall<'a, C> {
7186 self._delegate = Some(new_value);
7187 self
7188 }
7189
7190 /// Set any additional parameter of the query string used in the request.
7191 /// It should be used to set parameters which are not yet available through their own
7192 /// setters.
7193 ///
7194 /// Please note that this method must not be used to set any of the known parameters
7195 /// which have their own setter method. If done anyway, the request will fail.
7196 ///
7197 /// # Additional Parameters
7198 ///
7199 /// * *$.xgafv* (query-string) - V1 error format.
7200 /// * *access_token* (query-string) - OAuth access token.
7201 /// * *alt* (query-string) - Data format for response.
7202 /// * *callback* (query-string) - JSONP
7203 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7204 /// * *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.
7205 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7206 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7207 /// * *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.
7208 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7209 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7210 pub fn param<T>(mut self, name: T, value: T) -> ServiceListCall<'a, C>
7211 where
7212 T: AsRef<str>,
7213 {
7214 self._additional_params
7215 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7216 self
7217 }
7218
7219 /// Identifies the authorization scope for the method you are building.
7220 ///
7221 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7222 /// [`Scope::CloudBillingReadonly`].
7223 ///
7224 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7225 /// tokens for more than one scope.
7226 ///
7227 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7228 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7229 /// sufficient, a read-write scope will do as well.
7230 pub fn add_scope<St>(mut self, scope: St) -> ServiceListCall<'a, C>
7231 where
7232 St: AsRef<str>,
7233 {
7234 self._scopes.insert(String::from(scope.as_ref()));
7235 self
7236 }
7237 /// Identifies the authorization scope(s) for the method you are building.
7238 ///
7239 /// See [`Self::add_scope()`] for details.
7240 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceListCall<'a, C>
7241 where
7242 I: IntoIterator<Item = St>,
7243 St: AsRef<str>,
7244 {
7245 self._scopes
7246 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7247 self
7248 }
7249
7250 /// Removes all scopes, and no default scope will be used either.
7251 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7252 /// for details).
7253 pub fn clear_scopes(mut self) -> ServiceListCall<'a, C> {
7254 self._scopes.clear();
7255 self
7256 }
7257}