google_cloudcommerceprocurement1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudCommercePartnerProcurementService related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
49/// use cloudcommerceprocurement1::api::ApproveAccountRequest;
50/// use cloudcommerceprocurement1::{Result, Error};
51/// # async fn dox() {
52/// use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = ApproveAccountRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.providers().accounts_approve(req, "name")
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct CloudCommercePartnerProcurementService<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for CloudCommercePartnerProcurementService<C> {}
130
131impl<'a, C> CloudCommercePartnerProcurementService<C> {
132 pub fn new<A: 'static + common::GetToken>(
133 client: common::Client<C>,
134 auth: A,
135 ) -> CloudCommercePartnerProcurementService<C> {
136 CloudCommercePartnerProcurementService {
137 client,
138 auth: Box::new(auth),
139 _user_agent: "google-api-rust-client/7.0.0".to_string(),
140 _base_url: "https://cloudcommerceprocurement.googleapis.com/".to_string(),
141 _root_url: "https://cloudcommerceprocurement.googleapis.com/".to_string(),
142 }
143 }
144
145 pub fn providers(&'a self) -> ProviderMethods<'a, C> {
146 ProviderMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/7.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://cloudcommerceprocurement.googleapis.com/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://cloudcommerceprocurement.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// Represents an account that was established by the customer on the service provider’s system.
178///
179/// # Activities
180///
181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
183///
184/// * [accounts get providers](ProviderAccountGetCall) (response)
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct Account {
189 /// Output only. The approvals for this account. These approvals are used to track actions that are permitted or have been completed by a customer within the context of the provider. This might include a sign up flow or a provisioning step, for example, that the provider can admit to having happened.
190 pub approvals: Option<Vec<Approval>>,
191 /// Output only. The creation timestamp.
192 #[serde(rename = "createTime")]
193 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
194 /// Output only. The custom properties that were collected from the user to create this account.
195 #[serde(rename = "inputProperties")]
196 pub input_properties: Option<HashMap<String, serde_json::Value>>,
197 /// Output only. The resource name of the account. Account names have the form `accounts/{account_id}`.
198 pub name: Option<String>,
199 /// Output only. The identifier of the service provider that this account was created against. Each service provider is assigned a unique provider value when they onboard with Cloud Commerce platform.
200 pub provider: Option<String>,
201 /// Output only. The reseller parent billing account of the account's corresponding billing account, applicable only when the corresponding billing account is a subaccount of a reseller. Included in responses only for view: ACCOUNT_VIEW_FULL. Format: billingAccounts/{billing_account_id}
202 #[serde(rename = "resellerParentBillingAccount")]
203 pub reseller_parent_billing_account: Option<String>,
204 /// Output only. The state of the account. This is used to decide whether the customer is in good standing with the provider and is able to make purchases. An account might not be able to make a purchase if the billing account is suspended, for example.
205 pub state: Option<String>,
206 /// Output only. The last update timestamp.
207 #[serde(rename = "updateTime")]
208 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
209}
210
211impl common::ResponseResult for Account {}
212
213/// An approval for some action on an account.
214///
215/// This type is not used in any activity, and only used as *part* of another schema.
216///
217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
218#[serde_with::serde_as]
219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
220pub struct Approval {
221 /// Output only. The name of the approval.
222 pub name: Option<String>,
223 /// Output only. An explanation for the state of the approval.
224 pub reason: Option<String>,
225 /// Output only. The state of the approval.
226 pub state: Option<String>,
227 /// Optional. The last update timestamp of the approval.
228 #[serde(rename = "updateTime")]
229 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
230}
231
232impl common::Part for Approval {}
233
234/// Request message for PartnerProcurementService.ApproveAccount.
235///
236/// # Activities
237///
238/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
239/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
240///
241/// * [accounts approve providers](ProviderAccountApproveCall) (request)
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct ApproveAccountRequest {
246 /// The name of the approval being approved. If absent and there is only one approval possible, that approval will be granted. If absent and there are many approvals possible, the request will fail with a 400 Bad Request. Optional.
247 #[serde(rename = "approvalName")]
248 pub approval_name: Option<String>,
249 /// Set of properties that should be associated with the account. Optional.
250 pub properties: Option<HashMap<String, String>>,
251 /// Free form text string explaining the approval reason. Optional. Max allowed length: 256 bytes. Longer strings will be truncated.
252 pub reason: Option<String>,
253}
254
255impl common::RequestValue for ApproveAccountRequest {}
256
257/// Request message for \[PartnerProcurementService.ApproveEntitlementPlanChange\[\].
258///
259/// # Activities
260///
261/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
262/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
263///
264/// * [entitlements approve plan change providers](ProviderEntitlementApprovePlanChangeCall) (request)
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct ApproveEntitlementPlanChangeRequest {
269 /// Required. Name of the pending plan that's being approved.
270 #[serde(rename = "pendingPlanName")]
271 pub pending_plan_name: Option<String>,
272}
273
274impl common::RequestValue for ApproveEntitlementPlanChangeRequest {}
275
276/// Request message for \[PartnerProcurementService.ApproveEntitlement\[\].
277///
278/// # Activities
279///
280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
282///
283/// * [entitlements approve providers](ProviderEntitlementApproveCall) (request)
284#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
285#[serde_with::serde_as]
286#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
287pub struct ApproveEntitlementRequest {
288 /// Optional. The resource name of the entitlement that was migrated, with the format `providers/{provider_id}/entitlements/{entitlement_id}`. Should only be sent when resources have been migrated from entitlement_migrated to the new entitlement. Optional.
289 #[serde(rename = "entitlementMigrated")]
290 pub entitlement_migrated: Option<String>,
291 /// Set of properties that should be associated with the entitlement. Optional.
292 pub properties: Option<HashMap<String, String>>,
293}
294
295impl common::RequestValue for ApproveEntitlementRequest {}
296
297/// A resource using (consuming) this entitlement.
298///
299/// This type is not used in any activity, and only used as *part* of another schema.
300///
301#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
302#[serde_with::serde_as]
303#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
304pub struct Consumer {
305 /// A project name with format `projects/`.
306 pub project: Option<String>,
307}
308
309impl common::Part for Consumer {}
310
311/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [accounts approve providers](ProviderAccountApproveCall) (response)
319/// * [accounts reject providers](ProviderAccountRejectCall) (response)
320/// * [accounts reset providers](ProviderAccountResetCall) (response)
321/// * [entitlements approve providers](ProviderEntitlementApproveCall) (response)
322/// * [entitlements approve plan change providers](ProviderEntitlementApprovePlanChangeCall) (response)
323/// * [entitlements reject providers](ProviderEntitlementRejectCall) (response)
324/// * [entitlements reject plan change providers](ProviderEntitlementRejectPlanChangeCall) (response)
325/// * [entitlements suspend providers](ProviderEntitlementSuspendCall) (response)
326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
327#[serde_with::serde_as]
328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
329pub struct Empty {
330 _never_set: Option<bool>,
331}
332
333impl common::ResponseResult for Empty {}
334
335/// Represents a procured product of a customer.
336///
337/// # Activities
338///
339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
341///
342/// * [entitlements get providers](ProviderEntitlementGetCall) (response)
343/// * [entitlements patch providers](ProviderEntitlementPatchCall) (request|response)
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct Entitlement {
348 /// Output only. The resource name of the account that this entitlement is based on, if any.
349 pub account: Option<String>,
350 /// Output only. The reason the entitlement was cancelled. If this entitlement wasn't cancelled, this field is empty. Possible values include "unknown", "expired", "user-cancelled", "account-closed", "billing-disabled" (if the customer has manually disabled billing to their resources), "user-aborted", and "migrated" (if the entitlement has migrated across products). Values of this field are subject to change, and we recommend that you don't build your technical integration to rely on these fields.
351 #[serde(rename = "cancellationReason")]
352 pub cancellation_reason: Option<String>,
353 /// Output only. The resources using this entitlement, if applicable.
354 pub consumers: Option<Vec<Consumer>>,
355 /// Output only. The creation timestamp.
356 #[serde(rename = "createTime")]
357 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
358 /// Output only. The entitlement benefit IDs associated with the purchase.
359 #[serde(rename = "entitlementBenefitIds")]
360 pub entitlement_benefit_ids: Option<Vec<String>>,
361 /// Output only. The custom properties that were collected from the user to create this entitlement.
362 #[serde(rename = "inputProperties")]
363 pub input_properties: Option<HashMap<String, serde_json::Value>>,
364 /// Provider-supplied message that is displayed to the end user. Currently this is used to communicate progress and ETA for provisioning. This field can be updated only when a user is waiting for an action from the provider, i.e. entitlement state is EntitlementState.ENTITLEMENT_ACTIVATION_REQUESTED or EntitlementState.ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL. This field is cleared automatically when the entitlement state changes.
365 #[serde(rename = "messageToUser")]
366 pub message_to_user: Option<String>,
367 /// Output only. The resource name of the entitlement. Entitlement names have the form `providers/{provider_id}/entitlements/{entitlement_id}`.
368 pub name: Option<String>,
369 /// Output only. The end time of the new offer, determined from the offer's specified end date. If the offer des not have a specified end date then this field is not set. This field is populated even if the entitlement isn't active yet. If there's no upcoming offer, the field is empty. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, ENTITLEMENT_ACTIVE, or ENTITLEMENT_PENDING_CANCELLATION, then this field is empty. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL or ENTITLEMENT_PENDING_PLAN_CHANGE, and the upcoming offer has a specified end date, then this field is populated with the expected end time of the upcoming offer, in the future. Otherwise, this field is empty. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this field is empty.
370 #[serde(rename = "newOfferEndTime")]
371 pub new_offer_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
372 /// Output only. The timestamp when the new offer becomes effective. This field is populated even if the entitlement isn't active yet. If there's no upcoming offer, the field is empty. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, this field isn't populated when the entitlement isn't yet approved. After the entitlement is approved, this field is populated with the effective time of the upcoming offer. * If the entitlement is in the state ENTITLEMENT_ACTIVE or ENTITLEMENT_PENDING_CANCELLATION, this field isn't populated. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL, this field isn't populated, because the entitlement change is waiting on approval. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE, this field is populated with the expected effective time of the upcoming offer, which is in the future. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this field is empty.
373 #[serde(rename = "newOfferStartTime")]
374 pub new_offer_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
375 /// Output only. Upon a pending plan change, the name of the offer that the entitlement is switching to. Only exists if the pending plan change is moving to an offer. This field isn't populated for entitlements which aren't active yet. Format: 'projects/{project}/services/{service}/privateOffers/{offer}' OR 'projects/{project}/services/{service}/standardOffers/{offer}', depending on whether the offer is private or public. The {service} in the name is the listing service of the offer. It could be either the product service that the offer is referencing, or a generic private offer parent service. We recommend that you don't build your integration to rely on the meaning of this {service} part. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, ENTITLEMENT_ACTIVE or ENTITLEMENT_PENDING_CANCELLATION, then this field is empty. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL or ENTITLEMENT_PENDING_PLAN_CHANGE, then this field is populated with the upcoming offer. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this is empty.
376 #[serde(rename = "newPendingOffer")]
377 pub new_pending_offer: Option<String>,
378 /// Output only. The duration of the new offer, in ISO 8601 duration format. This field is populated for pending offer changes. It isn't populated for entitlements which aren't active yet. If the offer has a specified end date instead of a duration, this field is empty. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, ENTITLEMENT_ACTIVE, or ENTITLEMENT_PENDING_CANCELLATION, this field is empty. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL or ENTITLEMENT_PENDING_PLAN_CHANGE, and the upcoming offer doesn't have a specified end date, then this field is populated with the duration of the upcoming offer. Otherwise, this field is empty. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this field is empty.
379 #[serde(rename = "newPendingOfferDuration")]
380 pub new_pending_offer_duration: Option<String>,
381 /// Output only. The identifier of the pending new plan. Required if the product has plans and the entitlement has a pending plan change.
382 #[serde(rename = "newPendingPlan")]
383 pub new_pending_plan: Option<String>,
384 /// Output only. The name of the offer that was procured. Field is empty if order wasn't made using an offer. Format: 'projects/{project}/services/{service}/privateOffers/{offer}' OR 'projects/{project}/services/{service}/standardOffers/{offer}', depending on whether the offer is private or public. The {service} in the name is the listing service of the offer. It could be either the product service that the offer is referencing, or a generic private offer parent service. We recommend that you don't build your integration to rely on the meaning of this {service} part. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, this field is populated with the upcoming offer. * If the entitlement is in the state ENTITLEMENT_ACTIVE, ENTITLEMENT_PENDING_CANCELLATION, ENTITLEMENT_PENDING_PLAN_CHANGE, or ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL, this field is populated with the current offer. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this field is populated with the latest offer that the order was associated with.
385 pub offer: Option<String>,
386 /// Output only. The offer duration of the current offer, in ISO 8601 duration format. This is empty if the entitlement wasn't made using an offer, or if the offer has a specified end date instead of a duration. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, and the upcoming offer doesn't have a specified end date, then this field is populated with the duration of the upcoming offer. Otherwise, this field is empty. * If the entitlement is in the state ENTITLEMENT_ACTIVE, ENTITLEMENT_PENDING_CANCELLATION, ENTITLEMENT_PENDING_PLAN_CHANGE, or ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL, and the current offer doesn't have a specified end date, then this field contains the duration of the current offer. Otherwise, this field is empty. * If the entitlement is in the state ENTITLEMENT_CANCELLED, and the offer doesn't have a specified end date, then this field is populated with the duration of the latest offer that the order was associated with. Otherwise, this field is empty.
387 #[serde(rename = "offerDuration")]
388 pub offer_duration: Option<String>,
389 /// Output only. End time for the current term of the Offer associated with this entitlement. The value of this field can change naturally over time due to auto-renewal, even if the offer isn't changed. * If the entitlement is in the state ENTITLEMENT_ACTIVATION_REQUESTED, then: * If the entitlement isn't approved yet approved, and the offer has a specified end date, then this field is populated with the expected end time of the upcoming offer, in the future. Otherwise, this field is empty. * If the entitlement is approved, then this field is populated with the expected end time of the upcoming offer, in the future. This means that this field and the field offer_duration can both exist. * If the entitlement is in the state ENTITLEMENT_ACTIVE or ENTITLEMENT_PENDING_CANCELLATION, then this field is populated with the expected end time of the current offer, in the future. This field's value is set regardless of whether the offer has a specific end date or a duration. This means that this field and the field offer_duration can both exist. * If the entitlement is in the state ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL or ENTITLEMENT_PENDING_PLAN_CHANGE: * If the entitlement's pricing model is usage based and the associated offer is a private offer whose term has ended, then this field reflects the ACTUAL end time of the entitlement's associated offer (in the past), even though the entitlement associated with this private offer does not terminate at the end of that private offer's term. * Otherwise, this is the expected end date of the current offer, in the future. * If the entitlement is in the state ENTITLEMENT_CANCELLED, then this field is populated with the end time, in the past, of the latest offer that the order was associated with. If the entitlement was cancelled before any offer started, then this field is empty.
390 #[serde(rename = "offerEndTime")]
391 pub offer_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
392 /// Output only. The order ID of this entitlement, without any `orders/` resource name prefix.
393 #[serde(rename = "orderId")]
394 pub order_id: Option<String>,
395 /// Output only. The identifier of the plan that was procured. Required if the product has plans.
396 pub plan: Option<String>,
397 /// Output only. The identifier of the entity that was purchased. This may actually represent a product, quote, or offer. We strongly recommend that you use the following more explicit fields: productExternalName, quoteExternalName, or offer.
398 pub product: Option<String>,
399 /// Output only. The identifier of the product that was procured.
400 #[serde(rename = "productExternalName")]
401 pub product_external_name: Option<String>,
402 /// Output only. The identifier of the service provider that this entitlement was created against. Each service provider is assigned a unique provider value when they onboard with Cloud Commerce platform.
403 pub provider: Option<String>,
404 /// Output only. The identifier of the quote that was used to procure. Empty if the order is not purchased using a quote.
405 #[serde(rename = "quoteExternalName")]
406 pub quote_external_name: Option<String>,
407 /// Output only. The state of the entitlement.
408 pub state: Option<String>,
409 /// Output only. End time for the subscription corresponding to this entitlement.
410 #[serde(rename = "subscriptionEndTime")]
411 pub subscription_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
412 /// Output only. The last update timestamp.
413 #[serde(rename = "updateTime")]
414 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
415 /// Output only. The consumerId to use when reporting usage through the Service Control API. See the consumerId field at [Reporting Metrics](https://cloud.google.com/service-control/reporting-metrics) for more details. This field is present only if the product has usage-based billing configured.
416 #[serde(rename = "usageReportingId")]
417 pub usage_reporting_id: Option<String>,
418}
419
420impl common::RequestValue for Entitlement {}
421impl common::ResponseResult for Entitlement {}
422
423/// Response message for \[PartnerProcurementService.ListAccounts\[\].
424///
425/// # Activities
426///
427/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
428/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
429///
430/// * [accounts list providers](ProviderAccountListCall) (response)
431#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
432#[serde_with::serde_as]
433#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
434pub struct ListAccountsResponse {
435 /// The list of accounts in this response.
436 pub accounts: Option<Vec<Account>>,
437 /// The token for fetching the next page.
438 #[serde(rename = "nextPageToken")]
439 pub next_page_token: Option<String>,
440}
441
442impl common::ResponseResult for ListAccountsResponse {}
443
444/// Response message for PartnerProcurementService.ListEntitlements.
445///
446/// # Activities
447///
448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
450///
451/// * [entitlements list providers](ProviderEntitlementListCall) (response)
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct ListEntitlementsResponse {
456 /// The list of entitlements in this response.
457 pub entitlements: Option<Vec<Entitlement>>,
458 /// The token for fetching the next page.
459 #[serde(rename = "nextPageToken")]
460 pub next_page_token: Option<String>,
461}
462
463impl common::ResponseResult for ListEntitlementsResponse {}
464
465/// Request message for PartnerProcurementService.RejectAccount.
466///
467/// # Activities
468///
469/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
470/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
471///
472/// * [accounts reject providers](ProviderAccountRejectCall) (request)
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct RejectAccountRequest {
477 /// The name of the approval being rejected. If absent and there is only one approval possible, that approval will be rejected. If absent and there are many approvals possible, the request will fail with a 400 Bad Request. Optional.
478 #[serde(rename = "approvalName")]
479 pub approval_name: Option<String>,
480 /// Free form text string explaining the rejection reason. Max allowed length: 256 bytes. Longer strings will be truncated.
481 pub reason: Option<String>,
482}
483
484impl common::RequestValue for RejectAccountRequest {}
485
486/// Request message for PartnerProcurementService.RejectEntitlementPlanChange.
487///
488/// # Activities
489///
490/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
491/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
492///
493/// * [entitlements reject plan change providers](ProviderEntitlementRejectPlanChangeCall) (request)
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct RejectEntitlementPlanChangeRequest {
498 /// Required. Name of the pending plan that is being rejected.
499 #[serde(rename = "pendingPlanName")]
500 pub pending_plan_name: Option<String>,
501 /// Free form text string explaining the rejection reason. Max allowed length: 256 bytes. Longer strings will be truncated.
502 pub reason: Option<String>,
503}
504
505impl common::RequestValue for RejectEntitlementPlanChangeRequest {}
506
507/// Request message for PartnerProcurementService.RejectEntitlement.
508///
509/// # Activities
510///
511/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
512/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
513///
514/// * [entitlements reject providers](ProviderEntitlementRejectCall) (request)
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct RejectEntitlementRequest {
519 /// Free form text string explaining the rejection reason. Max allowed length: 256 bytes. Longer strings will be truncated.
520 pub reason: Option<String>,
521}
522
523impl common::RequestValue for RejectEntitlementRequest {}
524
525/// Request message for PartnerProcurementService.ResetAccount.
526///
527/// # Activities
528///
529/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
531///
532/// * [accounts reset providers](ProviderAccountResetCall) (request)
533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
534#[serde_with::serde_as]
535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
536pub struct ResetAccountRequest {
537 _never_set: Option<bool>,
538}
539
540impl common::RequestValue for ResetAccountRequest {}
541
542/// Request message for ParterProcurementService.SuspendEntitlement. This is not yet supported.
543///
544/// # Activities
545///
546/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
547/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
548///
549/// * [entitlements suspend providers](ProviderEntitlementSuspendCall) (request)
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct SuspendEntitlementRequest {
554 /// A free-form reason string, explaining the reason for suspension request.
555 pub reason: Option<String>,
556}
557
558impl common::RequestValue for SuspendEntitlementRequest {}
559
560// ###################
561// MethodBuilders ###
562// #################
563
564/// A builder providing access to all methods supported on *provider* resources.
565/// It is not used directly, but through the [`CloudCommercePartnerProcurementService`] hub.
566///
567/// # Example
568///
569/// Instantiate a resource builder
570///
571/// ```test_harness,no_run
572/// extern crate hyper;
573/// extern crate hyper_rustls;
574/// extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
575///
576/// # async fn dox() {
577/// use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
578///
579/// let secret: yup_oauth2::ApplicationSecret = Default::default();
580/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
581/// .with_native_roots()
582/// .unwrap()
583/// .https_only()
584/// .enable_http2()
585/// .build();
586///
587/// let executor = hyper_util::rt::TokioExecutor::new();
588/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
589/// secret,
590/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
591/// yup_oauth2::client::CustomHyperClientBuilder::from(
592/// hyper_util::client::legacy::Client::builder(executor).build(connector),
593/// ),
594/// ).build().await.unwrap();
595///
596/// let client = hyper_util::client::legacy::Client::builder(
597/// hyper_util::rt::TokioExecutor::new()
598/// )
599/// .build(
600/// hyper_rustls::HttpsConnectorBuilder::new()
601/// .with_native_roots()
602/// .unwrap()
603/// .https_or_http()
604/// .enable_http2()
605/// .build()
606/// );
607/// let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
608/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
609/// // like `accounts_approve(...)`, `accounts_get(...)`, `accounts_list(...)`, `accounts_reject(...)`, `accounts_reset(...)`, `entitlements_approve(...)`, `entitlements_approve_plan_change(...)`, `entitlements_get(...)`, `entitlements_list(...)`, `entitlements_patch(...)`, `entitlements_reject(...)`, `entitlements_reject_plan_change(...)` and `entitlements_suspend(...)`
610/// // to build up your call.
611/// let rb = hub.providers();
612/// # }
613/// ```
614pub struct ProviderMethods<'a, C>
615where
616 C: 'a,
617{
618 hub: &'a CloudCommercePartnerProcurementService<C>,
619}
620
621impl<'a, C> common::MethodsBuilder for ProviderMethods<'a, C> {}
622
623impl<'a, C> ProviderMethods<'a, C> {
624 /// Create a builder to help you perform the following task:
625 ///
626 /// Grants an approval on an Account.
627 ///
628 /// # Arguments
629 ///
630 /// * `request` - No description provided.
631 /// * `name` - Required. The resource name of the account, with the format `providers/{providerId}/accounts/{accountId}`.
632 pub fn accounts_approve(
633 &self,
634 request: ApproveAccountRequest,
635 name: &str,
636 ) -> ProviderAccountApproveCall<'a, C> {
637 ProviderAccountApproveCall {
638 hub: self.hub,
639 _request: request,
640 _name: name.to_string(),
641 _delegate: Default::default(),
642 _additional_params: Default::default(),
643 _scopes: Default::default(),
644 }
645 }
646
647 /// Create a builder to help you perform the following task:
648 ///
649 /// Gets a requested Account resource.
650 ///
651 /// # Arguments
652 ///
653 /// * `name` - Required. The name of the account to retrieve.
654 pub fn accounts_get(&self, name: &str) -> ProviderAccountGetCall<'a, C> {
655 ProviderAccountGetCall {
656 hub: self.hub,
657 _name: name.to_string(),
658 _view: Default::default(),
659 _delegate: Default::default(),
660 _additional_params: Default::default(),
661 _scopes: Default::default(),
662 }
663 }
664
665 /// Create a builder to help you perform the following task:
666 ///
667 /// Lists Accounts that the provider has access to.
668 ///
669 /// # Arguments
670 ///
671 /// * `parent` - Required. The parent resource name.
672 pub fn accounts_list(&self, parent: &str) -> ProviderAccountListCall<'a, C> {
673 ProviderAccountListCall {
674 hub: self.hub,
675 _parent: parent.to_string(),
676 _page_token: Default::default(),
677 _page_size: Default::default(),
678 _delegate: Default::default(),
679 _additional_params: Default::default(),
680 _scopes: Default::default(),
681 }
682 }
683
684 /// Create a builder to help you perform the following task:
685 ///
686 /// Rejects an approval on an Account.
687 ///
688 /// # Arguments
689 ///
690 /// * `request` - No description provided.
691 /// * `name` - Required. The resource name of the account.
692 pub fn accounts_reject(
693 &self,
694 request: RejectAccountRequest,
695 name: &str,
696 ) -> ProviderAccountRejectCall<'a, C> {
697 ProviderAccountRejectCall {
698 hub: self.hub,
699 _request: request,
700 _name: name.to_string(),
701 _delegate: Default::default(),
702 _additional_params: Default::default(),
703 _scopes: Default::default(),
704 }
705 }
706
707 /// Create a builder to help you perform the following task:
708 ///
709 /// Resets an Account and cancels all associated Entitlements. Partner can only reset accounts they own rather than customer accounts.
710 ///
711 /// # Arguments
712 ///
713 /// * `request` - No description provided.
714 /// * `name` - Required. The resource name of the account.
715 pub fn accounts_reset(
716 &self,
717 request: ResetAccountRequest,
718 name: &str,
719 ) -> ProviderAccountResetCall<'a, C> {
720 ProviderAccountResetCall {
721 hub: self.hub,
722 _request: request,
723 _name: name.to_string(),
724 _delegate: Default::default(),
725 _additional_params: Default::default(),
726 _scopes: Default::default(),
727 }
728 }
729
730 /// Create a builder to help you perform the following task:
731 ///
732 /// Approves an entitlement that is in the EntitlementState.ENTITLEMENT_ACTIVATION_REQUESTED state. This method is invoked by the provider to approve the creation of the entitlement resource.
733 ///
734 /// # Arguments
735 ///
736 /// * `request` - No description provided.
737 /// * `name` - Required. The resource name of the entitlement, with the format `providers/{providerId}/entitlements/{entitlementId}`.
738 pub fn entitlements_approve(
739 &self,
740 request: ApproveEntitlementRequest,
741 name: &str,
742 ) -> ProviderEntitlementApproveCall<'a, C> {
743 ProviderEntitlementApproveCall {
744 hub: self.hub,
745 _request: request,
746 _name: name.to_string(),
747 _delegate: Default::default(),
748 _additional_params: Default::default(),
749 _scopes: Default::default(),
750 }
751 }
752
753 /// Create a builder to help you perform the following task:
754 ///
755 /// Approves an entitlement plan change that is in the EntitlementState.ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL state. This method is invoked by the provider to approve the plan change on the entitlement resource.
756 ///
757 /// # Arguments
758 ///
759 /// * `request` - No description provided.
760 /// * `name` - Required. The resource name of the entitlement.
761 pub fn entitlements_approve_plan_change(
762 &self,
763 request: ApproveEntitlementPlanChangeRequest,
764 name: &str,
765 ) -> ProviderEntitlementApprovePlanChangeCall<'a, C> {
766 ProviderEntitlementApprovePlanChangeCall {
767 hub: self.hub,
768 _request: request,
769 _name: name.to_string(),
770 _delegate: Default::default(),
771 _additional_params: Default::default(),
772 _scopes: Default::default(),
773 }
774 }
775
776 /// Create a builder to help you perform the following task:
777 ///
778 /// Gets a requested Entitlement resource.
779 ///
780 /// # Arguments
781 ///
782 /// * `name` - Required. The name of the entitlement to retrieve.
783 pub fn entitlements_get(&self, name: &str) -> ProviderEntitlementGetCall<'a, C> {
784 ProviderEntitlementGetCall {
785 hub: self.hub,
786 _name: name.to_string(),
787 _delegate: Default::default(),
788 _additional_params: Default::default(),
789 _scopes: Default::default(),
790 }
791 }
792
793 /// Create a builder to help you perform the following task:
794 ///
795 /// Lists Entitlements for which the provider has read access.
796 ///
797 /// # Arguments
798 ///
799 /// * `parent` - Required. The parent resource name.
800 pub fn entitlements_list(&self, parent: &str) -> ProviderEntitlementListCall<'a, C> {
801 ProviderEntitlementListCall {
802 hub: self.hub,
803 _parent: parent.to_string(),
804 _page_token: Default::default(),
805 _page_size: Default::default(),
806 _filter: Default::default(),
807 _delegate: Default::default(),
808 _additional_params: Default::default(),
809 _scopes: Default::default(),
810 }
811 }
812
813 /// Create a builder to help you perform the following task:
814 ///
815 /// Updates an existing Entitlement.
816 ///
817 /// # Arguments
818 ///
819 /// * `request` - No description provided.
820 /// * `name` - Required. The name of the entitlement to update.
821 pub fn entitlements_patch(
822 &self,
823 request: Entitlement,
824 name: &str,
825 ) -> ProviderEntitlementPatchCall<'a, C> {
826 ProviderEntitlementPatchCall {
827 hub: self.hub,
828 _request: request,
829 _name: name.to_string(),
830 _update_mask: Default::default(),
831 _delegate: Default::default(),
832 _additional_params: Default::default(),
833 _scopes: Default::default(),
834 }
835 }
836
837 /// Create a builder to help you perform the following task:
838 ///
839 /// Rejects an entitlement that is in the EntitlementState.ENTITLEMENT_ACTIVATION_REQUESTED state. This method is invoked by the provider to reject the creation of the entitlement resource.
840 ///
841 /// # Arguments
842 ///
843 /// * `request` - No description provided.
844 /// * `name` - Required. The resource name of the entitlement.
845 pub fn entitlements_reject(
846 &self,
847 request: RejectEntitlementRequest,
848 name: &str,
849 ) -> ProviderEntitlementRejectCall<'a, C> {
850 ProviderEntitlementRejectCall {
851 hub: self.hub,
852 _request: request,
853 _name: name.to_string(),
854 _delegate: Default::default(),
855 _additional_params: Default::default(),
856 _scopes: Default::default(),
857 }
858 }
859
860 /// Create a builder to help you perform the following task:
861 ///
862 /// Rejects an entitlement plan change that is in the EntitlementState.ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL state. This method is invoked by the provider to reject the plan change on the entitlement resource.
863 ///
864 /// # Arguments
865 ///
866 /// * `request` - No description provided.
867 /// * `name` - Required. The resource name of the entitlement.
868 pub fn entitlements_reject_plan_change(
869 &self,
870 request: RejectEntitlementPlanChangeRequest,
871 name: &str,
872 ) -> ProviderEntitlementRejectPlanChangeCall<'a, C> {
873 ProviderEntitlementRejectPlanChangeCall {
874 hub: self.hub,
875 _request: request,
876 _name: name.to_string(),
877 _delegate: Default::default(),
878 _additional_params: Default::default(),
879 _scopes: Default::default(),
880 }
881 }
882
883 /// Create a builder to help you perform the following task:
884 ///
885 /// Requests suspension of an active Entitlement. This is not yet supported.
886 ///
887 /// # Arguments
888 ///
889 /// * `request` - No description provided.
890 /// * `name` - Required. The name of the entitlement to suspend.
891 pub fn entitlements_suspend(
892 &self,
893 request: SuspendEntitlementRequest,
894 name: &str,
895 ) -> ProviderEntitlementSuspendCall<'a, C> {
896 ProviderEntitlementSuspendCall {
897 hub: self.hub,
898 _request: request,
899 _name: name.to_string(),
900 _delegate: Default::default(),
901 _additional_params: Default::default(),
902 _scopes: Default::default(),
903 }
904 }
905}
906
907// ###################
908// CallBuilders ###
909// #################
910
911/// Grants an approval on an Account.
912///
913/// A builder for the *accounts.approve* method supported by a *provider* resource.
914/// It is not used directly, but through a [`ProviderMethods`] instance.
915///
916/// # Example
917///
918/// Instantiate a resource method builder
919///
920/// ```test_harness,no_run
921/// # extern crate hyper;
922/// # extern crate hyper_rustls;
923/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
924/// use cloudcommerceprocurement1::api::ApproveAccountRequest;
925/// # async fn dox() {
926/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
927///
928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
930/// # .with_native_roots()
931/// # .unwrap()
932/// # .https_only()
933/// # .enable_http2()
934/// # .build();
935///
936/// # let executor = hyper_util::rt::TokioExecutor::new();
937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
938/// # secret,
939/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
940/// # yup_oauth2::client::CustomHyperClientBuilder::from(
941/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
942/// # ),
943/// # ).build().await.unwrap();
944///
945/// # let client = hyper_util::client::legacy::Client::builder(
946/// # hyper_util::rt::TokioExecutor::new()
947/// # )
948/// # .build(
949/// # hyper_rustls::HttpsConnectorBuilder::new()
950/// # .with_native_roots()
951/// # .unwrap()
952/// # .https_or_http()
953/// # .enable_http2()
954/// # .build()
955/// # );
956/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
957/// // As the method needs a request, you would usually fill it with the desired information
958/// // into the respective structure. Some of the parts shown here might not be applicable !
959/// // Values shown here are possibly random and not representative !
960/// let mut req = ApproveAccountRequest::default();
961///
962/// // You can configure optional parameters by calling the respective setters at will, and
963/// // execute the final call using `doit()`.
964/// // Values shown here are possibly random and not representative !
965/// let result = hub.providers().accounts_approve(req, "name")
966/// .doit().await;
967/// # }
968/// ```
969pub struct ProviderAccountApproveCall<'a, C>
970where
971 C: 'a,
972{
973 hub: &'a CloudCommercePartnerProcurementService<C>,
974 _request: ApproveAccountRequest,
975 _name: String,
976 _delegate: Option<&'a mut dyn common::Delegate>,
977 _additional_params: HashMap<String, String>,
978 _scopes: BTreeSet<String>,
979}
980
981impl<'a, C> common::CallBuilder for ProviderAccountApproveCall<'a, C> {}
982
983impl<'a, C> ProviderAccountApproveCall<'a, C>
984where
985 C: common::Connector,
986{
987 /// Perform the operation you have build so far.
988 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
989 use std::borrow::Cow;
990 use std::io::{Read, Seek};
991
992 use common::{url::Params, ToParts};
993 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
994
995 let mut dd = common::DefaultDelegate;
996 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
997 dlg.begin(common::MethodInfo {
998 id: "cloudcommerceprocurement.providers.accounts.approve",
999 http_method: hyper::Method::POST,
1000 });
1001
1002 for &field in ["alt", "name"].iter() {
1003 if self._additional_params.contains_key(field) {
1004 dlg.finished(false);
1005 return Err(common::Error::FieldClash(field));
1006 }
1007 }
1008
1009 let mut params = Params::with_capacity(4 + self._additional_params.len());
1010 params.push("name", self._name);
1011
1012 params.extend(self._additional_params.iter());
1013
1014 params.push("alt", "json");
1015 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
1016 if self._scopes.is_empty() {
1017 self._scopes
1018 .insert(Scope::CloudPlatform.as_ref().to_string());
1019 }
1020
1021 #[allow(clippy::single_element_loop)]
1022 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1023 url = params.uri_replacement(url, param_name, find_this, true);
1024 }
1025 {
1026 let to_remove = ["name"];
1027 params.remove_params(&to_remove);
1028 }
1029
1030 let url = params.parse_with_url(&url);
1031
1032 let mut json_mime_type = mime::APPLICATION_JSON;
1033 let mut request_value_reader = {
1034 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1035 common::remove_json_null_values(&mut value);
1036 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1037 serde_json::to_writer(&mut dst, &value).unwrap();
1038 dst
1039 };
1040 let request_size = request_value_reader
1041 .seek(std::io::SeekFrom::End(0))
1042 .unwrap();
1043 request_value_reader
1044 .seek(std::io::SeekFrom::Start(0))
1045 .unwrap();
1046
1047 loop {
1048 let token = match self
1049 .hub
1050 .auth
1051 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1052 .await
1053 {
1054 Ok(token) => token,
1055 Err(e) => match dlg.token(e) {
1056 Ok(token) => token,
1057 Err(e) => {
1058 dlg.finished(false);
1059 return Err(common::Error::MissingToken(e));
1060 }
1061 },
1062 };
1063 request_value_reader
1064 .seek(std::io::SeekFrom::Start(0))
1065 .unwrap();
1066 let mut req_result = {
1067 let client = &self.hub.client;
1068 dlg.pre_request();
1069 let mut req_builder = hyper::Request::builder()
1070 .method(hyper::Method::POST)
1071 .uri(url.as_str())
1072 .header(USER_AGENT, self.hub._user_agent.clone());
1073
1074 if let Some(token) = token.as_ref() {
1075 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1076 }
1077
1078 let request = req_builder
1079 .header(CONTENT_TYPE, json_mime_type.to_string())
1080 .header(CONTENT_LENGTH, request_size as u64)
1081 .body(common::to_body(
1082 request_value_reader.get_ref().clone().into(),
1083 ));
1084
1085 client.request(request.unwrap()).await
1086 };
1087
1088 match req_result {
1089 Err(err) => {
1090 if let common::Retry::After(d) = dlg.http_error(&err) {
1091 sleep(d).await;
1092 continue;
1093 }
1094 dlg.finished(false);
1095 return Err(common::Error::HttpError(err));
1096 }
1097 Ok(res) => {
1098 let (mut parts, body) = res.into_parts();
1099 let mut body = common::Body::new(body);
1100 if !parts.status.is_success() {
1101 let bytes = common::to_bytes(body).await.unwrap_or_default();
1102 let error = serde_json::from_str(&common::to_string(&bytes));
1103 let response = common::to_response(parts, bytes.into());
1104
1105 if let common::Retry::After(d) =
1106 dlg.http_failure(&response, error.as_ref().ok())
1107 {
1108 sleep(d).await;
1109 continue;
1110 }
1111
1112 dlg.finished(false);
1113
1114 return Err(match error {
1115 Ok(value) => common::Error::BadRequest(value),
1116 _ => common::Error::Failure(response),
1117 });
1118 }
1119 let response = {
1120 let bytes = common::to_bytes(body).await.unwrap_or_default();
1121 let encoded = common::to_string(&bytes);
1122 match serde_json::from_str(&encoded) {
1123 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1124 Err(error) => {
1125 dlg.response_json_decode_error(&encoded, &error);
1126 return Err(common::Error::JsonDecodeError(
1127 encoded.to_string(),
1128 error,
1129 ));
1130 }
1131 }
1132 };
1133
1134 dlg.finished(true);
1135 return Ok(response);
1136 }
1137 }
1138 }
1139 }
1140
1141 ///
1142 /// Sets the *request* property to the given value.
1143 ///
1144 /// Even though the property as already been set when instantiating this call,
1145 /// we provide this method for API completeness.
1146 pub fn request(
1147 mut self,
1148 new_value: ApproveAccountRequest,
1149 ) -> ProviderAccountApproveCall<'a, C> {
1150 self._request = new_value;
1151 self
1152 }
1153 /// Required. The resource name of the account, with the format `providers/{providerId}/accounts/{accountId}`.
1154 ///
1155 /// Sets the *name* path property to the given value.
1156 ///
1157 /// Even though the property as already been set when instantiating this call,
1158 /// we provide this method for API completeness.
1159 pub fn name(mut self, new_value: &str) -> ProviderAccountApproveCall<'a, C> {
1160 self._name = new_value.to_string();
1161 self
1162 }
1163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1164 /// while executing the actual API request.
1165 ///
1166 /// ````text
1167 /// It should be used to handle progress information, and to implement a certain level of resilience.
1168 /// ````
1169 ///
1170 /// Sets the *delegate* property to the given value.
1171 pub fn delegate(
1172 mut self,
1173 new_value: &'a mut dyn common::Delegate,
1174 ) -> ProviderAccountApproveCall<'a, C> {
1175 self._delegate = Some(new_value);
1176 self
1177 }
1178
1179 /// Set any additional parameter of the query string used in the request.
1180 /// It should be used to set parameters which are not yet available through their own
1181 /// setters.
1182 ///
1183 /// Please note that this method must not be used to set any of the known parameters
1184 /// which have their own setter method. If done anyway, the request will fail.
1185 ///
1186 /// # Additional Parameters
1187 ///
1188 /// * *$.xgafv* (query-string) - V1 error format.
1189 /// * *access_token* (query-string) - OAuth access token.
1190 /// * *alt* (query-string) - Data format for response.
1191 /// * *callback* (query-string) - JSONP
1192 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1193 /// * *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.
1194 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1195 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1196 /// * *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.
1197 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1198 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1199 pub fn param<T>(mut self, name: T, value: T) -> ProviderAccountApproveCall<'a, C>
1200 where
1201 T: AsRef<str>,
1202 {
1203 self._additional_params
1204 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1205 self
1206 }
1207
1208 /// Identifies the authorization scope for the method you are building.
1209 ///
1210 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1211 /// [`Scope::CloudPlatform`].
1212 ///
1213 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1214 /// tokens for more than one scope.
1215 ///
1216 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1217 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1218 /// sufficient, a read-write scope will do as well.
1219 pub fn add_scope<St>(mut self, scope: St) -> ProviderAccountApproveCall<'a, C>
1220 where
1221 St: AsRef<str>,
1222 {
1223 self._scopes.insert(String::from(scope.as_ref()));
1224 self
1225 }
1226 /// Identifies the authorization scope(s) for the method you are building.
1227 ///
1228 /// See [`Self::add_scope()`] for details.
1229 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderAccountApproveCall<'a, C>
1230 where
1231 I: IntoIterator<Item = St>,
1232 St: AsRef<str>,
1233 {
1234 self._scopes
1235 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1236 self
1237 }
1238
1239 /// Removes all scopes, and no default scope will be used either.
1240 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1241 /// for details).
1242 pub fn clear_scopes(mut self) -> ProviderAccountApproveCall<'a, C> {
1243 self._scopes.clear();
1244 self
1245 }
1246}
1247
1248/// Gets a requested Account resource.
1249///
1250/// A builder for the *accounts.get* method supported by a *provider* resource.
1251/// It is not used directly, but through a [`ProviderMethods`] instance.
1252///
1253/// # Example
1254///
1255/// Instantiate a resource method builder
1256///
1257/// ```test_harness,no_run
1258/// # extern crate hyper;
1259/// # extern crate hyper_rustls;
1260/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
1261/// # async fn dox() {
1262/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1263///
1264/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1265/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1266/// # .with_native_roots()
1267/// # .unwrap()
1268/// # .https_only()
1269/// # .enable_http2()
1270/// # .build();
1271///
1272/// # let executor = hyper_util::rt::TokioExecutor::new();
1273/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1274/// # secret,
1275/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1276/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1277/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1278/// # ),
1279/// # ).build().await.unwrap();
1280///
1281/// # let client = hyper_util::client::legacy::Client::builder(
1282/// # hyper_util::rt::TokioExecutor::new()
1283/// # )
1284/// # .build(
1285/// # hyper_rustls::HttpsConnectorBuilder::new()
1286/// # .with_native_roots()
1287/// # .unwrap()
1288/// # .https_or_http()
1289/// # .enable_http2()
1290/// # .build()
1291/// # );
1292/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
1293/// // You can configure optional parameters by calling the respective setters at will, and
1294/// // execute the final call using `doit()`.
1295/// // Values shown here are possibly random and not representative !
1296/// let result = hub.providers().accounts_get("name")
1297/// .view("At")
1298/// .doit().await;
1299/// # }
1300/// ```
1301pub struct ProviderAccountGetCall<'a, C>
1302where
1303 C: 'a,
1304{
1305 hub: &'a CloudCommercePartnerProcurementService<C>,
1306 _name: String,
1307 _view: Option<String>,
1308 _delegate: Option<&'a mut dyn common::Delegate>,
1309 _additional_params: HashMap<String, String>,
1310 _scopes: BTreeSet<String>,
1311}
1312
1313impl<'a, C> common::CallBuilder for ProviderAccountGetCall<'a, C> {}
1314
1315impl<'a, C> ProviderAccountGetCall<'a, C>
1316where
1317 C: common::Connector,
1318{
1319 /// Perform the operation you have build so far.
1320 pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
1321 use std::borrow::Cow;
1322 use std::io::{Read, Seek};
1323
1324 use common::{url::Params, ToParts};
1325 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1326
1327 let mut dd = common::DefaultDelegate;
1328 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1329 dlg.begin(common::MethodInfo {
1330 id: "cloudcommerceprocurement.providers.accounts.get",
1331 http_method: hyper::Method::GET,
1332 });
1333
1334 for &field in ["alt", "name", "view"].iter() {
1335 if self._additional_params.contains_key(field) {
1336 dlg.finished(false);
1337 return Err(common::Error::FieldClash(field));
1338 }
1339 }
1340
1341 let mut params = Params::with_capacity(4 + self._additional_params.len());
1342 params.push("name", self._name);
1343 if let Some(value) = self._view.as_ref() {
1344 params.push("view", value);
1345 }
1346
1347 params.extend(self._additional_params.iter());
1348
1349 params.push("alt", "json");
1350 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1351 if self._scopes.is_empty() {
1352 self._scopes
1353 .insert(Scope::CloudPlatform.as_ref().to_string());
1354 }
1355
1356 #[allow(clippy::single_element_loop)]
1357 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1358 url = params.uri_replacement(url, param_name, find_this, true);
1359 }
1360 {
1361 let to_remove = ["name"];
1362 params.remove_params(&to_remove);
1363 }
1364
1365 let url = params.parse_with_url(&url);
1366
1367 loop {
1368 let token = match self
1369 .hub
1370 .auth
1371 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1372 .await
1373 {
1374 Ok(token) => token,
1375 Err(e) => match dlg.token(e) {
1376 Ok(token) => token,
1377 Err(e) => {
1378 dlg.finished(false);
1379 return Err(common::Error::MissingToken(e));
1380 }
1381 },
1382 };
1383 let mut req_result = {
1384 let client = &self.hub.client;
1385 dlg.pre_request();
1386 let mut req_builder = hyper::Request::builder()
1387 .method(hyper::Method::GET)
1388 .uri(url.as_str())
1389 .header(USER_AGENT, self.hub._user_agent.clone());
1390
1391 if let Some(token) = token.as_ref() {
1392 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1393 }
1394
1395 let request = req_builder
1396 .header(CONTENT_LENGTH, 0_u64)
1397 .body(common::to_body::<String>(None));
1398
1399 client.request(request.unwrap()).await
1400 };
1401
1402 match req_result {
1403 Err(err) => {
1404 if let common::Retry::After(d) = dlg.http_error(&err) {
1405 sleep(d).await;
1406 continue;
1407 }
1408 dlg.finished(false);
1409 return Err(common::Error::HttpError(err));
1410 }
1411 Ok(res) => {
1412 let (mut parts, body) = res.into_parts();
1413 let mut body = common::Body::new(body);
1414 if !parts.status.is_success() {
1415 let bytes = common::to_bytes(body).await.unwrap_or_default();
1416 let error = serde_json::from_str(&common::to_string(&bytes));
1417 let response = common::to_response(parts, bytes.into());
1418
1419 if let common::Retry::After(d) =
1420 dlg.http_failure(&response, error.as_ref().ok())
1421 {
1422 sleep(d).await;
1423 continue;
1424 }
1425
1426 dlg.finished(false);
1427
1428 return Err(match error {
1429 Ok(value) => common::Error::BadRequest(value),
1430 _ => common::Error::Failure(response),
1431 });
1432 }
1433 let response = {
1434 let bytes = common::to_bytes(body).await.unwrap_or_default();
1435 let encoded = common::to_string(&bytes);
1436 match serde_json::from_str(&encoded) {
1437 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1438 Err(error) => {
1439 dlg.response_json_decode_error(&encoded, &error);
1440 return Err(common::Error::JsonDecodeError(
1441 encoded.to_string(),
1442 error,
1443 ));
1444 }
1445 }
1446 };
1447
1448 dlg.finished(true);
1449 return Ok(response);
1450 }
1451 }
1452 }
1453 }
1454
1455 /// Required. The name of the account to retrieve.
1456 ///
1457 /// Sets the *name* path property to the given value.
1458 ///
1459 /// Even though the property as already been set when instantiating this call,
1460 /// we provide this method for API completeness.
1461 pub fn name(mut self, new_value: &str) -> ProviderAccountGetCall<'a, C> {
1462 self._name = new_value.to_string();
1463 self
1464 }
1465 /// Optional. What information to include in the response.
1466 ///
1467 /// Sets the *view* query property to the given value.
1468 pub fn view(mut self, new_value: &str) -> ProviderAccountGetCall<'a, C> {
1469 self._view = Some(new_value.to_string());
1470 self
1471 }
1472 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1473 /// while executing the actual API request.
1474 ///
1475 /// ````text
1476 /// It should be used to handle progress information, and to implement a certain level of resilience.
1477 /// ````
1478 ///
1479 /// Sets the *delegate* property to the given value.
1480 pub fn delegate(
1481 mut self,
1482 new_value: &'a mut dyn common::Delegate,
1483 ) -> ProviderAccountGetCall<'a, C> {
1484 self._delegate = Some(new_value);
1485 self
1486 }
1487
1488 /// Set any additional parameter of the query string used in the request.
1489 /// It should be used to set parameters which are not yet available through their own
1490 /// setters.
1491 ///
1492 /// Please note that this method must not be used to set any of the known parameters
1493 /// which have their own setter method. If done anyway, the request will fail.
1494 ///
1495 /// # Additional Parameters
1496 ///
1497 /// * *$.xgafv* (query-string) - V1 error format.
1498 /// * *access_token* (query-string) - OAuth access token.
1499 /// * *alt* (query-string) - Data format for response.
1500 /// * *callback* (query-string) - JSONP
1501 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1502 /// * *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.
1503 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1504 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1505 /// * *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.
1506 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1507 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1508 pub fn param<T>(mut self, name: T, value: T) -> ProviderAccountGetCall<'a, C>
1509 where
1510 T: AsRef<str>,
1511 {
1512 self._additional_params
1513 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1514 self
1515 }
1516
1517 /// Identifies the authorization scope for the method you are building.
1518 ///
1519 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1520 /// [`Scope::CloudPlatform`].
1521 ///
1522 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1523 /// tokens for more than one scope.
1524 ///
1525 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1526 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1527 /// sufficient, a read-write scope will do as well.
1528 pub fn add_scope<St>(mut self, scope: St) -> ProviderAccountGetCall<'a, C>
1529 where
1530 St: AsRef<str>,
1531 {
1532 self._scopes.insert(String::from(scope.as_ref()));
1533 self
1534 }
1535 /// Identifies the authorization scope(s) for the method you are building.
1536 ///
1537 /// See [`Self::add_scope()`] for details.
1538 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderAccountGetCall<'a, C>
1539 where
1540 I: IntoIterator<Item = St>,
1541 St: AsRef<str>,
1542 {
1543 self._scopes
1544 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1545 self
1546 }
1547
1548 /// Removes all scopes, and no default scope will be used either.
1549 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1550 /// for details).
1551 pub fn clear_scopes(mut self) -> ProviderAccountGetCall<'a, C> {
1552 self._scopes.clear();
1553 self
1554 }
1555}
1556
1557/// Lists Accounts that the provider has access to.
1558///
1559/// A builder for the *accounts.list* method supported by a *provider* resource.
1560/// It is not used directly, but through a [`ProviderMethods`] instance.
1561///
1562/// # Example
1563///
1564/// Instantiate a resource method builder
1565///
1566/// ```test_harness,no_run
1567/// # extern crate hyper;
1568/// # extern crate hyper_rustls;
1569/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
1570/// # async fn dox() {
1571/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1572///
1573/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1574/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1575/// # .with_native_roots()
1576/// # .unwrap()
1577/// # .https_only()
1578/// # .enable_http2()
1579/// # .build();
1580///
1581/// # let executor = hyper_util::rt::TokioExecutor::new();
1582/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1583/// # secret,
1584/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1585/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1586/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1587/// # ),
1588/// # ).build().await.unwrap();
1589///
1590/// # let client = hyper_util::client::legacy::Client::builder(
1591/// # hyper_util::rt::TokioExecutor::new()
1592/// # )
1593/// # .build(
1594/// # hyper_rustls::HttpsConnectorBuilder::new()
1595/// # .with_native_roots()
1596/// # .unwrap()
1597/// # .https_or_http()
1598/// # .enable_http2()
1599/// # .build()
1600/// # );
1601/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
1602/// // You can configure optional parameters by calling the respective setters at will, and
1603/// // execute the final call using `doit()`.
1604/// // Values shown here are possibly random and not representative !
1605/// let result = hub.providers().accounts_list("parent")
1606/// .page_token("sed")
1607/// .page_size(-2)
1608/// .doit().await;
1609/// # }
1610/// ```
1611pub struct ProviderAccountListCall<'a, C>
1612where
1613 C: 'a,
1614{
1615 hub: &'a CloudCommercePartnerProcurementService<C>,
1616 _parent: String,
1617 _page_token: Option<String>,
1618 _page_size: Option<i32>,
1619 _delegate: Option<&'a mut dyn common::Delegate>,
1620 _additional_params: HashMap<String, String>,
1621 _scopes: BTreeSet<String>,
1622}
1623
1624impl<'a, C> common::CallBuilder for ProviderAccountListCall<'a, C> {}
1625
1626impl<'a, C> ProviderAccountListCall<'a, C>
1627where
1628 C: common::Connector,
1629{
1630 /// Perform the operation you have build so far.
1631 pub async fn doit(mut self) -> common::Result<(common::Response, ListAccountsResponse)> {
1632 use std::borrow::Cow;
1633 use std::io::{Read, Seek};
1634
1635 use common::{url::Params, ToParts};
1636 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1637
1638 let mut dd = common::DefaultDelegate;
1639 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1640 dlg.begin(common::MethodInfo {
1641 id: "cloudcommerceprocurement.providers.accounts.list",
1642 http_method: hyper::Method::GET,
1643 });
1644
1645 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
1646 if self._additional_params.contains_key(field) {
1647 dlg.finished(false);
1648 return Err(common::Error::FieldClash(field));
1649 }
1650 }
1651
1652 let mut params = Params::with_capacity(5 + self._additional_params.len());
1653 params.push("parent", self._parent);
1654 if let Some(value) = self._page_token.as_ref() {
1655 params.push("pageToken", value);
1656 }
1657 if let Some(value) = self._page_size.as_ref() {
1658 params.push("pageSize", value.to_string());
1659 }
1660
1661 params.extend(self._additional_params.iter());
1662
1663 params.push("alt", "json");
1664 let mut url = self.hub._base_url.clone() + "v1/{+parent}/accounts";
1665 if self._scopes.is_empty() {
1666 self._scopes
1667 .insert(Scope::CloudPlatform.as_ref().to_string());
1668 }
1669
1670 #[allow(clippy::single_element_loop)]
1671 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1672 url = params.uri_replacement(url, param_name, find_this, true);
1673 }
1674 {
1675 let to_remove = ["parent"];
1676 params.remove_params(&to_remove);
1677 }
1678
1679 let url = params.parse_with_url(&url);
1680
1681 loop {
1682 let token = match self
1683 .hub
1684 .auth
1685 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1686 .await
1687 {
1688 Ok(token) => token,
1689 Err(e) => match dlg.token(e) {
1690 Ok(token) => token,
1691 Err(e) => {
1692 dlg.finished(false);
1693 return Err(common::Error::MissingToken(e));
1694 }
1695 },
1696 };
1697 let mut req_result = {
1698 let client = &self.hub.client;
1699 dlg.pre_request();
1700 let mut req_builder = hyper::Request::builder()
1701 .method(hyper::Method::GET)
1702 .uri(url.as_str())
1703 .header(USER_AGENT, self.hub._user_agent.clone());
1704
1705 if let Some(token) = token.as_ref() {
1706 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1707 }
1708
1709 let request = req_builder
1710 .header(CONTENT_LENGTH, 0_u64)
1711 .body(common::to_body::<String>(None));
1712
1713 client.request(request.unwrap()).await
1714 };
1715
1716 match req_result {
1717 Err(err) => {
1718 if let common::Retry::After(d) = dlg.http_error(&err) {
1719 sleep(d).await;
1720 continue;
1721 }
1722 dlg.finished(false);
1723 return Err(common::Error::HttpError(err));
1724 }
1725 Ok(res) => {
1726 let (mut parts, body) = res.into_parts();
1727 let mut body = common::Body::new(body);
1728 if !parts.status.is_success() {
1729 let bytes = common::to_bytes(body).await.unwrap_or_default();
1730 let error = serde_json::from_str(&common::to_string(&bytes));
1731 let response = common::to_response(parts, bytes.into());
1732
1733 if let common::Retry::After(d) =
1734 dlg.http_failure(&response, error.as_ref().ok())
1735 {
1736 sleep(d).await;
1737 continue;
1738 }
1739
1740 dlg.finished(false);
1741
1742 return Err(match error {
1743 Ok(value) => common::Error::BadRequest(value),
1744 _ => common::Error::Failure(response),
1745 });
1746 }
1747 let response = {
1748 let bytes = common::to_bytes(body).await.unwrap_or_default();
1749 let encoded = common::to_string(&bytes);
1750 match serde_json::from_str(&encoded) {
1751 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1752 Err(error) => {
1753 dlg.response_json_decode_error(&encoded, &error);
1754 return Err(common::Error::JsonDecodeError(
1755 encoded.to_string(),
1756 error,
1757 ));
1758 }
1759 }
1760 };
1761
1762 dlg.finished(true);
1763 return Ok(response);
1764 }
1765 }
1766 }
1767 }
1768
1769 /// Required. The parent resource name.
1770 ///
1771 /// Sets the *parent* path property to the given value.
1772 ///
1773 /// Even though the property as already been set when instantiating this call,
1774 /// we provide this method for API completeness.
1775 pub fn parent(mut self, new_value: &str) -> ProviderAccountListCall<'a, C> {
1776 self._parent = new_value.to_string();
1777 self
1778 }
1779 /// The token for fetching the next page.
1780 ///
1781 /// Sets the *page token* query property to the given value.
1782 pub fn page_token(mut self, new_value: &str) -> ProviderAccountListCall<'a, C> {
1783 self._page_token = Some(new_value.to_string());
1784 self
1785 }
1786 /// The maximum number of entries that are requested. The default page size is 25 and the maximum page size is 200.
1787 ///
1788 /// Sets the *page size* query property to the given value.
1789 pub fn page_size(mut self, new_value: i32) -> ProviderAccountListCall<'a, C> {
1790 self._page_size = Some(new_value);
1791 self
1792 }
1793 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1794 /// while executing the actual API request.
1795 ///
1796 /// ````text
1797 /// It should be used to handle progress information, and to implement a certain level of resilience.
1798 /// ````
1799 ///
1800 /// Sets the *delegate* property to the given value.
1801 pub fn delegate(
1802 mut self,
1803 new_value: &'a mut dyn common::Delegate,
1804 ) -> ProviderAccountListCall<'a, C> {
1805 self._delegate = Some(new_value);
1806 self
1807 }
1808
1809 /// Set any additional parameter of the query string used in the request.
1810 /// It should be used to set parameters which are not yet available through their own
1811 /// setters.
1812 ///
1813 /// Please note that this method must not be used to set any of the known parameters
1814 /// which have their own setter method. If done anyway, the request will fail.
1815 ///
1816 /// # Additional Parameters
1817 ///
1818 /// * *$.xgafv* (query-string) - V1 error format.
1819 /// * *access_token* (query-string) - OAuth access token.
1820 /// * *alt* (query-string) - Data format for response.
1821 /// * *callback* (query-string) - JSONP
1822 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1823 /// * *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.
1824 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1825 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1826 /// * *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.
1827 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1828 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1829 pub fn param<T>(mut self, name: T, value: T) -> ProviderAccountListCall<'a, C>
1830 where
1831 T: AsRef<str>,
1832 {
1833 self._additional_params
1834 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1835 self
1836 }
1837
1838 /// Identifies the authorization scope for the method you are building.
1839 ///
1840 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1841 /// [`Scope::CloudPlatform`].
1842 ///
1843 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1844 /// tokens for more than one scope.
1845 ///
1846 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1847 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1848 /// sufficient, a read-write scope will do as well.
1849 pub fn add_scope<St>(mut self, scope: St) -> ProviderAccountListCall<'a, C>
1850 where
1851 St: AsRef<str>,
1852 {
1853 self._scopes.insert(String::from(scope.as_ref()));
1854 self
1855 }
1856 /// Identifies the authorization scope(s) for the method you are building.
1857 ///
1858 /// See [`Self::add_scope()`] for details.
1859 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderAccountListCall<'a, C>
1860 where
1861 I: IntoIterator<Item = St>,
1862 St: AsRef<str>,
1863 {
1864 self._scopes
1865 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1866 self
1867 }
1868
1869 /// Removes all scopes, and no default scope will be used either.
1870 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1871 /// for details).
1872 pub fn clear_scopes(mut self) -> ProviderAccountListCall<'a, C> {
1873 self._scopes.clear();
1874 self
1875 }
1876}
1877
1878/// Rejects an approval on an Account.
1879///
1880/// A builder for the *accounts.reject* method supported by a *provider* resource.
1881/// It is not used directly, but through a [`ProviderMethods`] instance.
1882///
1883/// # Example
1884///
1885/// Instantiate a resource method builder
1886///
1887/// ```test_harness,no_run
1888/// # extern crate hyper;
1889/// # extern crate hyper_rustls;
1890/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
1891/// use cloudcommerceprocurement1::api::RejectAccountRequest;
1892/// # async fn dox() {
1893/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1894///
1895/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1896/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1897/// # .with_native_roots()
1898/// # .unwrap()
1899/// # .https_only()
1900/// # .enable_http2()
1901/// # .build();
1902///
1903/// # let executor = hyper_util::rt::TokioExecutor::new();
1904/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1905/// # secret,
1906/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1907/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1908/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1909/// # ),
1910/// # ).build().await.unwrap();
1911///
1912/// # let client = hyper_util::client::legacy::Client::builder(
1913/// # hyper_util::rt::TokioExecutor::new()
1914/// # )
1915/// # .build(
1916/// # hyper_rustls::HttpsConnectorBuilder::new()
1917/// # .with_native_roots()
1918/// # .unwrap()
1919/// # .https_or_http()
1920/// # .enable_http2()
1921/// # .build()
1922/// # );
1923/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
1924/// // As the method needs a request, you would usually fill it with the desired information
1925/// // into the respective structure. Some of the parts shown here might not be applicable !
1926/// // Values shown here are possibly random and not representative !
1927/// let mut req = RejectAccountRequest::default();
1928///
1929/// // You can configure optional parameters by calling the respective setters at will, and
1930/// // execute the final call using `doit()`.
1931/// // Values shown here are possibly random and not representative !
1932/// let result = hub.providers().accounts_reject(req, "name")
1933/// .doit().await;
1934/// # }
1935/// ```
1936pub struct ProviderAccountRejectCall<'a, C>
1937where
1938 C: 'a,
1939{
1940 hub: &'a CloudCommercePartnerProcurementService<C>,
1941 _request: RejectAccountRequest,
1942 _name: String,
1943 _delegate: Option<&'a mut dyn common::Delegate>,
1944 _additional_params: HashMap<String, String>,
1945 _scopes: BTreeSet<String>,
1946}
1947
1948impl<'a, C> common::CallBuilder for ProviderAccountRejectCall<'a, C> {}
1949
1950impl<'a, C> ProviderAccountRejectCall<'a, C>
1951where
1952 C: common::Connector,
1953{
1954 /// Perform the operation you have build so far.
1955 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1956 use std::borrow::Cow;
1957 use std::io::{Read, Seek};
1958
1959 use common::{url::Params, ToParts};
1960 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1961
1962 let mut dd = common::DefaultDelegate;
1963 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1964 dlg.begin(common::MethodInfo {
1965 id: "cloudcommerceprocurement.providers.accounts.reject",
1966 http_method: hyper::Method::POST,
1967 });
1968
1969 for &field in ["alt", "name"].iter() {
1970 if self._additional_params.contains_key(field) {
1971 dlg.finished(false);
1972 return Err(common::Error::FieldClash(field));
1973 }
1974 }
1975
1976 let mut params = Params::with_capacity(4 + self._additional_params.len());
1977 params.push("name", self._name);
1978
1979 params.extend(self._additional_params.iter());
1980
1981 params.push("alt", "json");
1982 let mut url = self.hub._base_url.clone() + "v1/{+name}:reject";
1983 if self._scopes.is_empty() {
1984 self._scopes
1985 .insert(Scope::CloudPlatform.as_ref().to_string());
1986 }
1987
1988 #[allow(clippy::single_element_loop)]
1989 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1990 url = params.uri_replacement(url, param_name, find_this, true);
1991 }
1992 {
1993 let to_remove = ["name"];
1994 params.remove_params(&to_remove);
1995 }
1996
1997 let url = params.parse_with_url(&url);
1998
1999 let mut json_mime_type = mime::APPLICATION_JSON;
2000 let mut request_value_reader = {
2001 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2002 common::remove_json_null_values(&mut value);
2003 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2004 serde_json::to_writer(&mut dst, &value).unwrap();
2005 dst
2006 };
2007 let request_size = request_value_reader
2008 .seek(std::io::SeekFrom::End(0))
2009 .unwrap();
2010 request_value_reader
2011 .seek(std::io::SeekFrom::Start(0))
2012 .unwrap();
2013
2014 loop {
2015 let token = match self
2016 .hub
2017 .auth
2018 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2019 .await
2020 {
2021 Ok(token) => token,
2022 Err(e) => match dlg.token(e) {
2023 Ok(token) => token,
2024 Err(e) => {
2025 dlg.finished(false);
2026 return Err(common::Error::MissingToken(e));
2027 }
2028 },
2029 };
2030 request_value_reader
2031 .seek(std::io::SeekFrom::Start(0))
2032 .unwrap();
2033 let mut req_result = {
2034 let client = &self.hub.client;
2035 dlg.pre_request();
2036 let mut req_builder = hyper::Request::builder()
2037 .method(hyper::Method::POST)
2038 .uri(url.as_str())
2039 .header(USER_AGENT, self.hub._user_agent.clone());
2040
2041 if let Some(token) = token.as_ref() {
2042 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2043 }
2044
2045 let request = req_builder
2046 .header(CONTENT_TYPE, json_mime_type.to_string())
2047 .header(CONTENT_LENGTH, request_size as u64)
2048 .body(common::to_body(
2049 request_value_reader.get_ref().clone().into(),
2050 ));
2051
2052 client.request(request.unwrap()).await
2053 };
2054
2055 match req_result {
2056 Err(err) => {
2057 if let common::Retry::After(d) = dlg.http_error(&err) {
2058 sleep(d).await;
2059 continue;
2060 }
2061 dlg.finished(false);
2062 return Err(common::Error::HttpError(err));
2063 }
2064 Ok(res) => {
2065 let (mut parts, body) = res.into_parts();
2066 let mut body = common::Body::new(body);
2067 if !parts.status.is_success() {
2068 let bytes = common::to_bytes(body).await.unwrap_or_default();
2069 let error = serde_json::from_str(&common::to_string(&bytes));
2070 let response = common::to_response(parts, bytes.into());
2071
2072 if let common::Retry::After(d) =
2073 dlg.http_failure(&response, error.as_ref().ok())
2074 {
2075 sleep(d).await;
2076 continue;
2077 }
2078
2079 dlg.finished(false);
2080
2081 return Err(match error {
2082 Ok(value) => common::Error::BadRequest(value),
2083 _ => common::Error::Failure(response),
2084 });
2085 }
2086 let response = {
2087 let bytes = common::to_bytes(body).await.unwrap_or_default();
2088 let encoded = common::to_string(&bytes);
2089 match serde_json::from_str(&encoded) {
2090 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2091 Err(error) => {
2092 dlg.response_json_decode_error(&encoded, &error);
2093 return Err(common::Error::JsonDecodeError(
2094 encoded.to_string(),
2095 error,
2096 ));
2097 }
2098 }
2099 };
2100
2101 dlg.finished(true);
2102 return Ok(response);
2103 }
2104 }
2105 }
2106 }
2107
2108 ///
2109 /// Sets the *request* property to the given value.
2110 ///
2111 /// Even though the property as already been set when instantiating this call,
2112 /// we provide this method for API completeness.
2113 pub fn request(mut self, new_value: RejectAccountRequest) -> ProviderAccountRejectCall<'a, C> {
2114 self._request = new_value;
2115 self
2116 }
2117 /// Required. The resource name of the account.
2118 ///
2119 /// Sets the *name* path property to the given value.
2120 ///
2121 /// Even though the property as already been set when instantiating this call,
2122 /// we provide this method for API completeness.
2123 pub fn name(mut self, new_value: &str) -> ProviderAccountRejectCall<'a, C> {
2124 self._name = new_value.to_string();
2125 self
2126 }
2127 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2128 /// while executing the actual API request.
2129 ///
2130 /// ````text
2131 /// It should be used to handle progress information, and to implement a certain level of resilience.
2132 /// ````
2133 ///
2134 /// Sets the *delegate* property to the given value.
2135 pub fn delegate(
2136 mut self,
2137 new_value: &'a mut dyn common::Delegate,
2138 ) -> ProviderAccountRejectCall<'a, C> {
2139 self._delegate = Some(new_value);
2140 self
2141 }
2142
2143 /// Set any additional parameter of the query string used in the request.
2144 /// It should be used to set parameters which are not yet available through their own
2145 /// setters.
2146 ///
2147 /// Please note that this method must not be used to set any of the known parameters
2148 /// which have their own setter method. If done anyway, the request will fail.
2149 ///
2150 /// # Additional Parameters
2151 ///
2152 /// * *$.xgafv* (query-string) - V1 error format.
2153 /// * *access_token* (query-string) - OAuth access token.
2154 /// * *alt* (query-string) - Data format for response.
2155 /// * *callback* (query-string) - JSONP
2156 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2157 /// * *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.
2158 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2159 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2160 /// * *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.
2161 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2162 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2163 pub fn param<T>(mut self, name: T, value: T) -> ProviderAccountRejectCall<'a, C>
2164 where
2165 T: AsRef<str>,
2166 {
2167 self._additional_params
2168 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2169 self
2170 }
2171
2172 /// Identifies the authorization scope for the method you are building.
2173 ///
2174 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2175 /// [`Scope::CloudPlatform`].
2176 ///
2177 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2178 /// tokens for more than one scope.
2179 ///
2180 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2181 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2182 /// sufficient, a read-write scope will do as well.
2183 pub fn add_scope<St>(mut self, scope: St) -> ProviderAccountRejectCall<'a, C>
2184 where
2185 St: AsRef<str>,
2186 {
2187 self._scopes.insert(String::from(scope.as_ref()));
2188 self
2189 }
2190 /// Identifies the authorization scope(s) for the method you are building.
2191 ///
2192 /// See [`Self::add_scope()`] for details.
2193 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderAccountRejectCall<'a, C>
2194 where
2195 I: IntoIterator<Item = St>,
2196 St: AsRef<str>,
2197 {
2198 self._scopes
2199 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2200 self
2201 }
2202
2203 /// Removes all scopes, and no default scope will be used either.
2204 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2205 /// for details).
2206 pub fn clear_scopes(mut self) -> ProviderAccountRejectCall<'a, C> {
2207 self._scopes.clear();
2208 self
2209 }
2210}
2211
2212/// Resets an Account and cancels all associated Entitlements. Partner can only reset accounts they own rather than customer accounts.
2213///
2214/// A builder for the *accounts.reset* method supported by a *provider* resource.
2215/// It is not used directly, but through a [`ProviderMethods`] instance.
2216///
2217/// # Example
2218///
2219/// Instantiate a resource method builder
2220///
2221/// ```test_harness,no_run
2222/// # extern crate hyper;
2223/// # extern crate hyper_rustls;
2224/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
2225/// use cloudcommerceprocurement1::api::ResetAccountRequest;
2226/// # async fn dox() {
2227/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2228///
2229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2230/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2231/// # .with_native_roots()
2232/// # .unwrap()
2233/// # .https_only()
2234/// # .enable_http2()
2235/// # .build();
2236///
2237/// # let executor = hyper_util::rt::TokioExecutor::new();
2238/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2239/// # secret,
2240/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2241/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2242/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2243/// # ),
2244/// # ).build().await.unwrap();
2245///
2246/// # let client = hyper_util::client::legacy::Client::builder(
2247/// # hyper_util::rt::TokioExecutor::new()
2248/// # )
2249/// # .build(
2250/// # hyper_rustls::HttpsConnectorBuilder::new()
2251/// # .with_native_roots()
2252/// # .unwrap()
2253/// # .https_or_http()
2254/// # .enable_http2()
2255/// # .build()
2256/// # );
2257/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
2258/// // As the method needs a request, you would usually fill it with the desired information
2259/// // into the respective structure. Some of the parts shown here might not be applicable !
2260/// // Values shown here are possibly random and not representative !
2261/// let mut req = ResetAccountRequest::default();
2262///
2263/// // You can configure optional parameters by calling the respective setters at will, and
2264/// // execute the final call using `doit()`.
2265/// // Values shown here are possibly random and not representative !
2266/// let result = hub.providers().accounts_reset(req, "name")
2267/// .doit().await;
2268/// # }
2269/// ```
2270pub struct ProviderAccountResetCall<'a, C>
2271where
2272 C: 'a,
2273{
2274 hub: &'a CloudCommercePartnerProcurementService<C>,
2275 _request: ResetAccountRequest,
2276 _name: String,
2277 _delegate: Option<&'a mut dyn common::Delegate>,
2278 _additional_params: HashMap<String, String>,
2279 _scopes: BTreeSet<String>,
2280}
2281
2282impl<'a, C> common::CallBuilder for ProviderAccountResetCall<'a, C> {}
2283
2284impl<'a, C> ProviderAccountResetCall<'a, C>
2285where
2286 C: common::Connector,
2287{
2288 /// Perform the operation you have build so far.
2289 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2290 use std::borrow::Cow;
2291 use std::io::{Read, Seek};
2292
2293 use common::{url::Params, ToParts};
2294 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2295
2296 let mut dd = common::DefaultDelegate;
2297 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2298 dlg.begin(common::MethodInfo {
2299 id: "cloudcommerceprocurement.providers.accounts.reset",
2300 http_method: hyper::Method::POST,
2301 });
2302
2303 for &field in ["alt", "name"].iter() {
2304 if self._additional_params.contains_key(field) {
2305 dlg.finished(false);
2306 return Err(common::Error::FieldClash(field));
2307 }
2308 }
2309
2310 let mut params = Params::with_capacity(4 + self._additional_params.len());
2311 params.push("name", self._name);
2312
2313 params.extend(self._additional_params.iter());
2314
2315 params.push("alt", "json");
2316 let mut url = self.hub._base_url.clone() + "v1/{+name}:reset";
2317 if self._scopes.is_empty() {
2318 self._scopes
2319 .insert(Scope::CloudPlatform.as_ref().to_string());
2320 }
2321
2322 #[allow(clippy::single_element_loop)]
2323 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2324 url = params.uri_replacement(url, param_name, find_this, true);
2325 }
2326 {
2327 let to_remove = ["name"];
2328 params.remove_params(&to_remove);
2329 }
2330
2331 let url = params.parse_with_url(&url);
2332
2333 let mut json_mime_type = mime::APPLICATION_JSON;
2334 let mut request_value_reader = {
2335 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2336 common::remove_json_null_values(&mut value);
2337 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2338 serde_json::to_writer(&mut dst, &value).unwrap();
2339 dst
2340 };
2341 let request_size = request_value_reader
2342 .seek(std::io::SeekFrom::End(0))
2343 .unwrap();
2344 request_value_reader
2345 .seek(std::io::SeekFrom::Start(0))
2346 .unwrap();
2347
2348 loop {
2349 let token = match self
2350 .hub
2351 .auth
2352 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2353 .await
2354 {
2355 Ok(token) => token,
2356 Err(e) => match dlg.token(e) {
2357 Ok(token) => token,
2358 Err(e) => {
2359 dlg.finished(false);
2360 return Err(common::Error::MissingToken(e));
2361 }
2362 },
2363 };
2364 request_value_reader
2365 .seek(std::io::SeekFrom::Start(0))
2366 .unwrap();
2367 let mut req_result = {
2368 let client = &self.hub.client;
2369 dlg.pre_request();
2370 let mut req_builder = hyper::Request::builder()
2371 .method(hyper::Method::POST)
2372 .uri(url.as_str())
2373 .header(USER_AGENT, self.hub._user_agent.clone());
2374
2375 if let Some(token) = token.as_ref() {
2376 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2377 }
2378
2379 let request = req_builder
2380 .header(CONTENT_TYPE, json_mime_type.to_string())
2381 .header(CONTENT_LENGTH, request_size as u64)
2382 .body(common::to_body(
2383 request_value_reader.get_ref().clone().into(),
2384 ));
2385
2386 client.request(request.unwrap()).await
2387 };
2388
2389 match req_result {
2390 Err(err) => {
2391 if let common::Retry::After(d) = dlg.http_error(&err) {
2392 sleep(d).await;
2393 continue;
2394 }
2395 dlg.finished(false);
2396 return Err(common::Error::HttpError(err));
2397 }
2398 Ok(res) => {
2399 let (mut parts, body) = res.into_parts();
2400 let mut body = common::Body::new(body);
2401 if !parts.status.is_success() {
2402 let bytes = common::to_bytes(body).await.unwrap_or_default();
2403 let error = serde_json::from_str(&common::to_string(&bytes));
2404 let response = common::to_response(parts, bytes.into());
2405
2406 if let common::Retry::After(d) =
2407 dlg.http_failure(&response, error.as_ref().ok())
2408 {
2409 sleep(d).await;
2410 continue;
2411 }
2412
2413 dlg.finished(false);
2414
2415 return Err(match error {
2416 Ok(value) => common::Error::BadRequest(value),
2417 _ => common::Error::Failure(response),
2418 });
2419 }
2420 let response = {
2421 let bytes = common::to_bytes(body).await.unwrap_or_default();
2422 let encoded = common::to_string(&bytes);
2423 match serde_json::from_str(&encoded) {
2424 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2425 Err(error) => {
2426 dlg.response_json_decode_error(&encoded, &error);
2427 return Err(common::Error::JsonDecodeError(
2428 encoded.to_string(),
2429 error,
2430 ));
2431 }
2432 }
2433 };
2434
2435 dlg.finished(true);
2436 return Ok(response);
2437 }
2438 }
2439 }
2440 }
2441
2442 ///
2443 /// Sets the *request* property to the given value.
2444 ///
2445 /// Even though the property as already been set when instantiating this call,
2446 /// we provide this method for API completeness.
2447 pub fn request(mut self, new_value: ResetAccountRequest) -> ProviderAccountResetCall<'a, C> {
2448 self._request = new_value;
2449 self
2450 }
2451 /// Required. The resource name of the account.
2452 ///
2453 /// Sets the *name* path property to the given value.
2454 ///
2455 /// Even though the property as already been set when instantiating this call,
2456 /// we provide this method for API completeness.
2457 pub fn name(mut self, new_value: &str) -> ProviderAccountResetCall<'a, C> {
2458 self._name = new_value.to_string();
2459 self
2460 }
2461 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2462 /// while executing the actual API request.
2463 ///
2464 /// ````text
2465 /// It should be used to handle progress information, and to implement a certain level of resilience.
2466 /// ````
2467 ///
2468 /// Sets the *delegate* property to the given value.
2469 pub fn delegate(
2470 mut self,
2471 new_value: &'a mut dyn common::Delegate,
2472 ) -> ProviderAccountResetCall<'a, C> {
2473 self._delegate = Some(new_value);
2474 self
2475 }
2476
2477 /// Set any additional parameter of the query string used in the request.
2478 /// It should be used to set parameters which are not yet available through their own
2479 /// setters.
2480 ///
2481 /// Please note that this method must not be used to set any of the known parameters
2482 /// which have their own setter method. If done anyway, the request will fail.
2483 ///
2484 /// # Additional Parameters
2485 ///
2486 /// * *$.xgafv* (query-string) - V1 error format.
2487 /// * *access_token* (query-string) - OAuth access token.
2488 /// * *alt* (query-string) - Data format for response.
2489 /// * *callback* (query-string) - JSONP
2490 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2491 /// * *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.
2492 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2493 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2494 /// * *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.
2495 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2496 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2497 pub fn param<T>(mut self, name: T, value: T) -> ProviderAccountResetCall<'a, C>
2498 where
2499 T: AsRef<str>,
2500 {
2501 self._additional_params
2502 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2503 self
2504 }
2505
2506 /// Identifies the authorization scope for the method you are building.
2507 ///
2508 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2509 /// [`Scope::CloudPlatform`].
2510 ///
2511 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2512 /// tokens for more than one scope.
2513 ///
2514 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2515 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2516 /// sufficient, a read-write scope will do as well.
2517 pub fn add_scope<St>(mut self, scope: St) -> ProviderAccountResetCall<'a, C>
2518 where
2519 St: AsRef<str>,
2520 {
2521 self._scopes.insert(String::from(scope.as_ref()));
2522 self
2523 }
2524 /// Identifies the authorization scope(s) for the method you are building.
2525 ///
2526 /// See [`Self::add_scope()`] for details.
2527 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderAccountResetCall<'a, C>
2528 where
2529 I: IntoIterator<Item = St>,
2530 St: AsRef<str>,
2531 {
2532 self._scopes
2533 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2534 self
2535 }
2536
2537 /// Removes all scopes, and no default scope will be used either.
2538 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2539 /// for details).
2540 pub fn clear_scopes(mut self) -> ProviderAccountResetCall<'a, C> {
2541 self._scopes.clear();
2542 self
2543 }
2544}
2545
2546/// Approves an entitlement that is in the EntitlementState.ENTITLEMENT_ACTIVATION_REQUESTED state. This method is invoked by the provider to approve the creation of the entitlement resource.
2547///
2548/// A builder for the *entitlements.approve* method supported by a *provider* resource.
2549/// It is not used directly, but through a [`ProviderMethods`] instance.
2550///
2551/// # Example
2552///
2553/// Instantiate a resource method builder
2554///
2555/// ```test_harness,no_run
2556/// # extern crate hyper;
2557/// # extern crate hyper_rustls;
2558/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
2559/// use cloudcommerceprocurement1::api::ApproveEntitlementRequest;
2560/// # async fn dox() {
2561/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2562///
2563/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2564/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2565/// # .with_native_roots()
2566/// # .unwrap()
2567/// # .https_only()
2568/// # .enable_http2()
2569/// # .build();
2570///
2571/// # let executor = hyper_util::rt::TokioExecutor::new();
2572/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2573/// # secret,
2574/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2575/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2576/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2577/// # ),
2578/// # ).build().await.unwrap();
2579///
2580/// # let client = hyper_util::client::legacy::Client::builder(
2581/// # hyper_util::rt::TokioExecutor::new()
2582/// # )
2583/// # .build(
2584/// # hyper_rustls::HttpsConnectorBuilder::new()
2585/// # .with_native_roots()
2586/// # .unwrap()
2587/// # .https_or_http()
2588/// # .enable_http2()
2589/// # .build()
2590/// # );
2591/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
2592/// // As the method needs a request, you would usually fill it with the desired information
2593/// // into the respective structure. Some of the parts shown here might not be applicable !
2594/// // Values shown here are possibly random and not representative !
2595/// let mut req = ApproveEntitlementRequest::default();
2596///
2597/// // You can configure optional parameters by calling the respective setters at will, and
2598/// // execute the final call using `doit()`.
2599/// // Values shown here are possibly random and not representative !
2600/// let result = hub.providers().entitlements_approve(req, "name")
2601/// .doit().await;
2602/// # }
2603/// ```
2604pub struct ProviderEntitlementApproveCall<'a, C>
2605where
2606 C: 'a,
2607{
2608 hub: &'a CloudCommercePartnerProcurementService<C>,
2609 _request: ApproveEntitlementRequest,
2610 _name: String,
2611 _delegate: Option<&'a mut dyn common::Delegate>,
2612 _additional_params: HashMap<String, String>,
2613 _scopes: BTreeSet<String>,
2614}
2615
2616impl<'a, C> common::CallBuilder for ProviderEntitlementApproveCall<'a, C> {}
2617
2618impl<'a, C> ProviderEntitlementApproveCall<'a, C>
2619where
2620 C: common::Connector,
2621{
2622 /// Perform the operation you have build so far.
2623 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2624 use std::borrow::Cow;
2625 use std::io::{Read, Seek};
2626
2627 use common::{url::Params, ToParts};
2628 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2629
2630 let mut dd = common::DefaultDelegate;
2631 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2632 dlg.begin(common::MethodInfo {
2633 id: "cloudcommerceprocurement.providers.entitlements.approve",
2634 http_method: hyper::Method::POST,
2635 });
2636
2637 for &field in ["alt", "name"].iter() {
2638 if self._additional_params.contains_key(field) {
2639 dlg.finished(false);
2640 return Err(common::Error::FieldClash(field));
2641 }
2642 }
2643
2644 let mut params = Params::with_capacity(4 + self._additional_params.len());
2645 params.push("name", self._name);
2646
2647 params.extend(self._additional_params.iter());
2648
2649 params.push("alt", "json");
2650 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
2651 if self._scopes.is_empty() {
2652 self._scopes
2653 .insert(Scope::CloudPlatform.as_ref().to_string());
2654 }
2655
2656 #[allow(clippy::single_element_loop)]
2657 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2658 url = params.uri_replacement(url, param_name, find_this, true);
2659 }
2660 {
2661 let to_remove = ["name"];
2662 params.remove_params(&to_remove);
2663 }
2664
2665 let url = params.parse_with_url(&url);
2666
2667 let mut json_mime_type = mime::APPLICATION_JSON;
2668 let mut request_value_reader = {
2669 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2670 common::remove_json_null_values(&mut value);
2671 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2672 serde_json::to_writer(&mut dst, &value).unwrap();
2673 dst
2674 };
2675 let request_size = request_value_reader
2676 .seek(std::io::SeekFrom::End(0))
2677 .unwrap();
2678 request_value_reader
2679 .seek(std::io::SeekFrom::Start(0))
2680 .unwrap();
2681
2682 loop {
2683 let token = match self
2684 .hub
2685 .auth
2686 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2687 .await
2688 {
2689 Ok(token) => token,
2690 Err(e) => match dlg.token(e) {
2691 Ok(token) => token,
2692 Err(e) => {
2693 dlg.finished(false);
2694 return Err(common::Error::MissingToken(e));
2695 }
2696 },
2697 };
2698 request_value_reader
2699 .seek(std::io::SeekFrom::Start(0))
2700 .unwrap();
2701 let mut req_result = {
2702 let client = &self.hub.client;
2703 dlg.pre_request();
2704 let mut req_builder = hyper::Request::builder()
2705 .method(hyper::Method::POST)
2706 .uri(url.as_str())
2707 .header(USER_AGENT, self.hub._user_agent.clone());
2708
2709 if let Some(token) = token.as_ref() {
2710 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2711 }
2712
2713 let request = req_builder
2714 .header(CONTENT_TYPE, json_mime_type.to_string())
2715 .header(CONTENT_LENGTH, request_size as u64)
2716 .body(common::to_body(
2717 request_value_reader.get_ref().clone().into(),
2718 ));
2719
2720 client.request(request.unwrap()).await
2721 };
2722
2723 match req_result {
2724 Err(err) => {
2725 if let common::Retry::After(d) = dlg.http_error(&err) {
2726 sleep(d).await;
2727 continue;
2728 }
2729 dlg.finished(false);
2730 return Err(common::Error::HttpError(err));
2731 }
2732 Ok(res) => {
2733 let (mut parts, body) = res.into_parts();
2734 let mut body = common::Body::new(body);
2735 if !parts.status.is_success() {
2736 let bytes = common::to_bytes(body).await.unwrap_or_default();
2737 let error = serde_json::from_str(&common::to_string(&bytes));
2738 let response = common::to_response(parts, bytes.into());
2739
2740 if let common::Retry::After(d) =
2741 dlg.http_failure(&response, error.as_ref().ok())
2742 {
2743 sleep(d).await;
2744 continue;
2745 }
2746
2747 dlg.finished(false);
2748
2749 return Err(match error {
2750 Ok(value) => common::Error::BadRequest(value),
2751 _ => common::Error::Failure(response),
2752 });
2753 }
2754 let response = {
2755 let bytes = common::to_bytes(body).await.unwrap_or_default();
2756 let encoded = common::to_string(&bytes);
2757 match serde_json::from_str(&encoded) {
2758 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2759 Err(error) => {
2760 dlg.response_json_decode_error(&encoded, &error);
2761 return Err(common::Error::JsonDecodeError(
2762 encoded.to_string(),
2763 error,
2764 ));
2765 }
2766 }
2767 };
2768
2769 dlg.finished(true);
2770 return Ok(response);
2771 }
2772 }
2773 }
2774 }
2775
2776 ///
2777 /// Sets the *request* property to the given value.
2778 ///
2779 /// Even though the property as already been set when instantiating this call,
2780 /// we provide this method for API completeness.
2781 pub fn request(
2782 mut self,
2783 new_value: ApproveEntitlementRequest,
2784 ) -> ProviderEntitlementApproveCall<'a, C> {
2785 self._request = new_value;
2786 self
2787 }
2788 /// Required. The resource name of the entitlement, with the format `providers/{providerId}/entitlements/{entitlementId}`.
2789 ///
2790 /// Sets the *name* path property to the given value.
2791 ///
2792 /// Even though the property as already been set when instantiating this call,
2793 /// we provide this method for API completeness.
2794 pub fn name(mut self, new_value: &str) -> ProviderEntitlementApproveCall<'a, C> {
2795 self._name = new_value.to_string();
2796 self
2797 }
2798 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2799 /// while executing the actual API request.
2800 ///
2801 /// ````text
2802 /// It should be used to handle progress information, and to implement a certain level of resilience.
2803 /// ````
2804 ///
2805 /// Sets the *delegate* property to the given value.
2806 pub fn delegate(
2807 mut self,
2808 new_value: &'a mut dyn common::Delegate,
2809 ) -> ProviderEntitlementApproveCall<'a, C> {
2810 self._delegate = Some(new_value);
2811 self
2812 }
2813
2814 /// Set any additional parameter of the query string used in the request.
2815 /// It should be used to set parameters which are not yet available through their own
2816 /// setters.
2817 ///
2818 /// Please note that this method must not be used to set any of the known parameters
2819 /// which have their own setter method. If done anyway, the request will fail.
2820 ///
2821 /// # Additional Parameters
2822 ///
2823 /// * *$.xgafv* (query-string) - V1 error format.
2824 /// * *access_token* (query-string) - OAuth access token.
2825 /// * *alt* (query-string) - Data format for response.
2826 /// * *callback* (query-string) - JSONP
2827 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2828 /// * *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.
2829 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2830 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2831 /// * *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.
2832 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2833 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2834 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementApproveCall<'a, C>
2835 where
2836 T: AsRef<str>,
2837 {
2838 self._additional_params
2839 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2840 self
2841 }
2842
2843 /// Identifies the authorization scope for the method you are building.
2844 ///
2845 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2846 /// [`Scope::CloudPlatform`].
2847 ///
2848 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2849 /// tokens for more than one scope.
2850 ///
2851 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2852 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2853 /// sufficient, a read-write scope will do as well.
2854 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementApproveCall<'a, C>
2855 where
2856 St: AsRef<str>,
2857 {
2858 self._scopes.insert(String::from(scope.as_ref()));
2859 self
2860 }
2861 /// Identifies the authorization scope(s) for the method you are building.
2862 ///
2863 /// See [`Self::add_scope()`] for details.
2864 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementApproveCall<'a, C>
2865 where
2866 I: IntoIterator<Item = St>,
2867 St: AsRef<str>,
2868 {
2869 self._scopes
2870 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2871 self
2872 }
2873
2874 /// Removes all scopes, and no default scope will be used either.
2875 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2876 /// for details).
2877 pub fn clear_scopes(mut self) -> ProviderEntitlementApproveCall<'a, C> {
2878 self._scopes.clear();
2879 self
2880 }
2881}
2882
2883/// Approves an entitlement plan change that is in the EntitlementState.ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL state. This method is invoked by the provider to approve the plan change on the entitlement resource.
2884///
2885/// A builder for the *entitlements.approvePlanChange* method supported by a *provider* resource.
2886/// It is not used directly, but through a [`ProviderMethods`] instance.
2887///
2888/// # Example
2889///
2890/// Instantiate a resource method builder
2891///
2892/// ```test_harness,no_run
2893/// # extern crate hyper;
2894/// # extern crate hyper_rustls;
2895/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
2896/// use cloudcommerceprocurement1::api::ApproveEntitlementPlanChangeRequest;
2897/// # async fn dox() {
2898/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2899///
2900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2902/// # .with_native_roots()
2903/// # .unwrap()
2904/// # .https_only()
2905/// # .enable_http2()
2906/// # .build();
2907///
2908/// # let executor = hyper_util::rt::TokioExecutor::new();
2909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2910/// # secret,
2911/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2912/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2913/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2914/// # ),
2915/// # ).build().await.unwrap();
2916///
2917/// # let client = hyper_util::client::legacy::Client::builder(
2918/// # hyper_util::rt::TokioExecutor::new()
2919/// # )
2920/// # .build(
2921/// # hyper_rustls::HttpsConnectorBuilder::new()
2922/// # .with_native_roots()
2923/// # .unwrap()
2924/// # .https_or_http()
2925/// # .enable_http2()
2926/// # .build()
2927/// # );
2928/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
2929/// // As the method needs a request, you would usually fill it with the desired information
2930/// // into the respective structure. Some of the parts shown here might not be applicable !
2931/// // Values shown here are possibly random and not representative !
2932/// let mut req = ApproveEntitlementPlanChangeRequest::default();
2933///
2934/// // You can configure optional parameters by calling the respective setters at will, and
2935/// // execute the final call using `doit()`.
2936/// // Values shown here are possibly random and not representative !
2937/// let result = hub.providers().entitlements_approve_plan_change(req, "name")
2938/// .doit().await;
2939/// # }
2940/// ```
2941pub struct ProviderEntitlementApprovePlanChangeCall<'a, C>
2942where
2943 C: 'a,
2944{
2945 hub: &'a CloudCommercePartnerProcurementService<C>,
2946 _request: ApproveEntitlementPlanChangeRequest,
2947 _name: String,
2948 _delegate: Option<&'a mut dyn common::Delegate>,
2949 _additional_params: HashMap<String, String>,
2950 _scopes: BTreeSet<String>,
2951}
2952
2953impl<'a, C> common::CallBuilder for ProviderEntitlementApprovePlanChangeCall<'a, C> {}
2954
2955impl<'a, C> ProviderEntitlementApprovePlanChangeCall<'a, C>
2956where
2957 C: common::Connector,
2958{
2959 /// Perform the operation you have build so far.
2960 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2961 use std::borrow::Cow;
2962 use std::io::{Read, Seek};
2963
2964 use common::{url::Params, ToParts};
2965 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2966
2967 let mut dd = common::DefaultDelegate;
2968 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2969 dlg.begin(common::MethodInfo {
2970 id: "cloudcommerceprocurement.providers.entitlements.approvePlanChange",
2971 http_method: hyper::Method::POST,
2972 });
2973
2974 for &field in ["alt", "name"].iter() {
2975 if self._additional_params.contains_key(field) {
2976 dlg.finished(false);
2977 return Err(common::Error::FieldClash(field));
2978 }
2979 }
2980
2981 let mut params = Params::with_capacity(4 + self._additional_params.len());
2982 params.push("name", self._name);
2983
2984 params.extend(self._additional_params.iter());
2985
2986 params.push("alt", "json");
2987 let mut url = self.hub._base_url.clone() + "v1/{+name}:approvePlanChange";
2988 if self._scopes.is_empty() {
2989 self._scopes
2990 .insert(Scope::CloudPlatform.as_ref().to_string());
2991 }
2992
2993 #[allow(clippy::single_element_loop)]
2994 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2995 url = params.uri_replacement(url, param_name, find_this, true);
2996 }
2997 {
2998 let to_remove = ["name"];
2999 params.remove_params(&to_remove);
3000 }
3001
3002 let url = params.parse_with_url(&url);
3003
3004 let mut json_mime_type = mime::APPLICATION_JSON;
3005 let mut request_value_reader = {
3006 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3007 common::remove_json_null_values(&mut value);
3008 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3009 serde_json::to_writer(&mut dst, &value).unwrap();
3010 dst
3011 };
3012 let request_size = request_value_reader
3013 .seek(std::io::SeekFrom::End(0))
3014 .unwrap();
3015 request_value_reader
3016 .seek(std::io::SeekFrom::Start(0))
3017 .unwrap();
3018
3019 loop {
3020 let token = match self
3021 .hub
3022 .auth
3023 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3024 .await
3025 {
3026 Ok(token) => token,
3027 Err(e) => match dlg.token(e) {
3028 Ok(token) => token,
3029 Err(e) => {
3030 dlg.finished(false);
3031 return Err(common::Error::MissingToken(e));
3032 }
3033 },
3034 };
3035 request_value_reader
3036 .seek(std::io::SeekFrom::Start(0))
3037 .unwrap();
3038 let mut req_result = {
3039 let client = &self.hub.client;
3040 dlg.pre_request();
3041 let mut req_builder = hyper::Request::builder()
3042 .method(hyper::Method::POST)
3043 .uri(url.as_str())
3044 .header(USER_AGENT, self.hub._user_agent.clone());
3045
3046 if let Some(token) = token.as_ref() {
3047 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3048 }
3049
3050 let request = req_builder
3051 .header(CONTENT_TYPE, json_mime_type.to_string())
3052 .header(CONTENT_LENGTH, request_size as u64)
3053 .body(common::to_body(
3054 request_value_reader.get_ref().clone().into(),
3055 ));
3056
3057 client.request(request.unwrap()).await
3058 };
3059
3060 match req_result {
3061 Err(err) => {
3062 if let common::Retry::After(d) = dlg.http_error(&err) {
3063 sleep(d).await;
3064 continue;
3065 }
3066 dlg.finished(false);
3067 return Err(common::Error::HttpError(err));
3068 }
3069 Ok(res) => {
3070 let (mut parts, body) = res.into_parts();
3071 let mut body = common::Body::new(body);
3072 if !parts.status.is_success() {
3073 let bytes = common::to_bytes(body).await.unwrap_or_default();
3074 let error = serde_json::from_str(&common::to_string(&bytes));
3075 let response = common::to_response(parts, bytes.into());
3076
3077 if let common::Retry::After(d) =
3078 dlg.http_failure(&response, error.as_ref().ok())
3079 {
3080 sleep(d).await;
3081 continue;
3082 }
3083
3084 dlg.finished(false);
3085
3086 return Err(match error {
3087 Ok(value) => common::Error::BadRequest(value),
3088 _ => common::Error::Failure(response),
3089 });
3090 }
3091 let response = {
3092 let bytes = common::to_bytes(body).await.unwrap_or_default();
3093 let encoded = common::to_string(&bytes);
3094 match serde_json::from_str(&encoded) {
3095 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3096 Err(error) => {
3097 dlg.response_json_decode_error(&encoded, &error);
3098 return Err(common::Error::JsonDecodeError(
3099 encoded.to_string(),
3100 error,
3101 ));
3102 }
3103 }
3104 };
3105
3106 dlg.finished(true);
3107 return Ok(response);
3108 }
3109 }
3110 }
3111 }
3112
3113 ///
3114 /// Sets the *request* property to the given value.
3115 ///
3116 /// Even though the property as already been set when instantiating this call,
3117 /// we provide this method for API completeness.
3118 pub fn request(
3119 mut self,
3120 new_value: ApproveEntitlementPlanChangeRequest,
3121 ) -> ProviderEntitlementApprovePlanChangeCall<'a, C> {
3122 self._request = new_value;
3123 self
3124 }
3125 /// Required. The resource name of the entitlement.
3126 ///
3127 /// Sets the *name* path property to the given value.
3128 ///
3129 /// Even though the property as already been set when instantiating this call,
3130 /// we provide this method for API completeness.
3131 pub fn name(mut self, new_value: &str) -> ProviderEntitlementApprovePlanChangeCall<'a, C> {
3132 self._name = new_value.to_string();
3133 self
3134 }
3135 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3136 /// while executing the actual API request.
3137 ///
3138 /// ````text
3139 /// It should be used to handle progress information, and to implement a certain level of resilience.
3140 /// ````
3141 ///
3142 /// Sets the *delegate* property to the given value.
3143 pub fn delegate(
3144 mut self,
3145 new_value: &'a mut dyn common::Delegate,
3146 ) -> ProviderEntitlementApprovePlanChangeCall<'a, C> {
3147 self._delegate = Some(new_value);
3148 self
3149 }
3150
3151 /// Set any additional parameter of the query string used in the request.
3152 /// It should be used to set parameters which are not yet available through their own
3153 /// setters.
3154 ///
3155 /// Please note that this method must not be used to set any of the known parameters
3156 /// which have their own setter method. If done anyway, the request will fail.
3157 ///
3158 /// # Additional Parameters
3159 ///
3160 /// * *$.xgafv* (query-string) - V1 error format.
3161 /// * *access_token* (query-string) - OAuth access token.
3162 /// * *alt* (query-string) - Data format for response.
3163 /// * *callback* (query-string) - JSONP
3164 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3165 /// * *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.
3166 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3167 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3168 /// * *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.
3169 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3170 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3171 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementApprovePlanChangeCall<'a, C>
3172 where
3173 T: AsRef<str>,
3174 {
3175 self._additional_params
3176 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3177 self
3178 }
3179
3180 /// Identifies the authorization scope for the method you are building.
3181 ///
3182 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3183 /// [`Scope::CloudPlatform`].
3184 ///
3185 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3186 /// tokens for more than one scope.
3187 ///
3188 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3189 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3190 /// sufficient, a read-write scope will do as well.
3191 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementApprovePlanChangeCall<'a, C>
3192 where
3193 St: AsRef<str>,
3194 {
3195 self._scopes.insert(String::from(scope.as_ref()));
3196 self
3197 }
3198 /// Identifies the authorization scope(s) for the method you are building.
3199 ///
3200 /// See [`Self::add_scope()`] for details.
3201 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementApprovePlanChangeCall<'a, C>
3202 where
3203 I: IntoIterator<Item = St>,
3204 St: AsRef<str>,
3205 {
3206 self._scopes
3207 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3208 self
3209 }
3210
3211 /// Removes all scopes, and no default scope will be used either.
3212 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3213 /// for details).
3214 pub fn clear_scopes(mut self) -> ProviderEntitlementApprovePlanChangeCall<'a, C> {
3215 self._scopes.clear();
3216 self
3217 }
3218}
3219
3220/// Gets a requested Entitlement resource.
3221///
3222/// A builder for the *entitlements.get* method supported by a *provider* resource.
3223/// It is not used directly, but through a [`ProviderMethods`] instance.
3224///
3225/// # Example
3226///
3227/// Instantiate a resource method builder
3228///
3229/// ```test_harness,no_run
3230/// # extern crate hyper;
3231/// # extern crate hyper_rustls;
3232/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
3233/// # async fn dox() {
3234/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3235///
3236/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3237/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3238/// # .with_native_roots()
3239/// # .unwrap()
3240/// # .https_only()
3241/// # .enable_http2()
3242/// # .build();
3243///
3244/// # let executor = hyper_util::rt::TokioExecutor::new();
3245/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3246/// # secret,
3247/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3248/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3249/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3250/// # ),
3251/// # ).build().await.unwrap();
3252///
3253/// # let client = hyper_util::client::legacy::Client::builder(
3254/// # hyper_util::rt::TokioExecutor::new()
3255/// # )
3256/// # .build(
3257/// # hyper_rustls::HttpsConnectorBuilder::new()
3258/// # .with_native_roots()
3259/// # .unwrap()
3260/// # .https_or_http()
3261/// # .enable_http2()
3262/// # .build()
3263/// # );
3264/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
3265/// // You can configure optional parameters by calling the respective setters at will, and
3266/// // execute the final call using `doit()`.
3267/// // Values shown here are possibly random and not representative !
3268/// let result = hub.providers().entitlements_get("name")
3269/// .doit().await;
3270/// # }
3271/// ```
3272pub struct ProviderEntitlementGetCall<'a, C>
3273where
3274 C: 'a,
3275{
3276 hub: &'a CloudCommercePartnerProcurementService<C>,
3277 _name: String,
3278 _delegate: Option<&'a mut dyn common::Delegate>,
3279 _additional_params: HashMap<String, String>,
3280 _scopes: BTreeSet<String>,
3281}
3282
3283impl<'a, C> common::CallBuilder for ProviderEntitlementGetCall<'a, C> {}
3284
3285impl<'a, C> ProviderEntitlementGetCall<'a, C>
3286where
3287 C: common::Connector,
3288{
3289 /// Perform the operation you have build so far.
3290 pub async fn doit(mut self) -> common::Result<(common::Response, Entitlement)> {
3291 use std::borrow::Cow;
3292 use std::io::{Read, Seek};
3293
3294 use common::{url::Params, ToParts};
3295 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3296
3297 let mut dd = common::DefaultDelegate;
3298 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3299 dlg.begin(common::MethodInfo {
3300 id: "cloudcommerceprocurement.providers.entitlements.get",
3301 http_method: hyper::Method::GET,
3302 });
3303
3304 for &field in ["alt", "name"].iter() {
3305 if self._additional_params.contains_key(field) {
3306 dlg.finished(false);
3307 return Err(common::Error::FieldClash(field));
3308 }
3309 }
3310
3311 let mut params = Params::with_capacity(3 + self._additional_params.len());
3312 params.push("name", self._name);
3313
3314 params.extend(self._additional_params.iter());
3315
3316 params.push("alt", "json");
3317 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3318 if self._scopes.is_empty() {
3319 self._scopes
3320 .insert(Scope::CloudPlatform.as_ref().to_string());
3321 }
3322
3323 #[allow(clippy::single_element_loop)]
3324 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3325 url = params.uri_replacement(url, param_name, find_this, true);
3326 }
3327 {
3328 let to_remove = ["name"];
3329 params.remove_params(&to_remove);
3330 }
3331
3332 let url = params.parse_with_url(&url);
3333
3334 loop {
3335 let token = match self
3336 .hub
3337 .auth
3338 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3339 .await
3340 {
3341 Ok(token) => token,
3342 Err(e) => match dlg.token(e) {
3343 Ok(token) => token,
3344 Err(e) => {
3345 dlg.finished(false);
3346 return Err(common::Error::MissingToken(e));
3347 }
3348 },
3349 };
3350 let mut req_result = {
3351 let client = &self.hub.client;
3352 dlg.pre_request();
3353 let mut req_builder = hyper::Request::builder()
3354 .method(hyper::Method::GET)
3355 .uri(url.as_str())
3356 .header(USER_AGENT, self.hub._user_agent.clone());
3357
3358 if let Some(token) = token.as_ref() {
3359 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3360 }
3361
3362 let request = req_builder
3363 .header(CONTENT_LENGTH, 0_u64)
3364 .body(common::to_body::<String>(None));
3365
3366 client.request(request.unwrap()).await
3367 };
3368
3369 match req_result {
3370 Err(err) => {
3371 if let common::Retry::After(d) = dlg.http_error(&err) {
3372 sleep(d).await;
3373 continue;
3374 }
3375 dlg.finished(false);
3376 return Err(common::Error::HttpError(err));
3377 }
3378 Ok(res) => {
3379 let (mut parts, body) = res.into_parts();
3380 let mut body = common::Body::new(body);
3381 if !parts.status.is_success() {
3382 let bytes = common::to_bytes(body).await.unwrap_or_default();
3383 let error = serde_json::from_str(&common::to_string(&bytes));
3384 let response = common::to_response(parts, bytes.into());
3385
3386 if let common::Retry::After(d) =
3387 dlg.http_failure(&response, error.as_ref().ok())
3388 {
3389 sleep(d).await;
3390 continue;
3391 }
3392
3393 dlg.finished(false);
3394
3395 return Err(match error {
3396 Ok(value) => common::Error::BadRequest(value),
3397 _ => common::Error::Failure(response),
3398 });
3399 }
3400 let response = {
3401 let bytes = common::to_bytes(body).await.unwrap_or_default();
3402 let encoded = common::to_string(&bytes);
3403 match serde_json::from_str(&encoded) {
3404 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3405 Err(error) => {
3406 dlg.response_json_decode_error(&encoded, &error);
3407 return Err(common::Error::JsonDecodeError(
3408 encoded.to_string(),
3409 error,
3410 ));
3411 }
3412 }
3413 };
3414
3415 dlg.finished(true);
3416 return Ok(response);
3417 }
3418 }
3419 }
3420 }
3421
3422 /// Required. The name of the entitlement to retrieve.
3423 ///
3424 /// Sets the *name* path property to the given value.
3425 ///
3426 /// Even though the property as already been set when instantiating this call,
3427 /// we provide this method for API completeness.
3428 pub fn name(mut self, new_value: &str) -> ProviderEntitlementGetCall<'a, C> {
3429 self._name = new_value.to_string();
3430 self
3431 }
3432 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3433 /// while executing the actual API request.
3434 ///
3435 /// ````text
3436 /// It should be used to handle progress information, and to implement a certain level of resilience.
3437 /// ````
3438 ///
3439 /// Sets the *delegate* property to the given value.
3440 pub fn delegate(
3441 mut self,
3442 new_value: &'a mut dyn common::Delegate,
3443 ) -> ProviderEntitlementGetCall<'a, C> {
3444 self._delegate = Some(new_value);
3445 self
3446 }
3447
3448 /// Set any additional parameter of the query string used in the request.
3449 /// It should be used to set parameters which are not yet available through their own
3450 /// setters.
3451 ///
3452 /// Please note that this method must not be used to set any of the known parameters
3453 /// which have their own setter method. If done anyway, the request will fail.
3454 ///
3455 /// # Additional Parameters
3456 ///
3457 /// * *$.xgafv* (query-string) - V1 error format.
3458 /// * *access_token* (query-string) - OAuth access token.
3459 /// * *alt* (query-string) - Data format for response.
3460 /// * *callback* (query-string) - JSONP
3461 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3462 /// * *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.
3463 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3464 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3465 /// * *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.
3466 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3467 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3468 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementGetCall<'a, C>
3469 where
3470 T: AsRef<str>,
3471 {
3472 self._additional_params
3473 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3474 self
3475 }
3476
3477 /// Identifies the authorization scope for the method you are building.
3478 ///
3479 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3480 /// [`Scope::CloudPlatform`].
3481 ///
3482 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3483 /// tokens for more than one scope.
3484 ///
3485 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3486 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3487 /// sufficient, a read-write scope will do as well.
3488 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementGetCall<'a, C>
3489 where
3490 St: AsRef<str>,
3491 {
3492 self._scopes.insert(String::from(scope.as_ref()));
3493 self
3494 }
3495 /// Identifies the authorization scope(s) for the method you are building.
3496 ///
3497 /// See [`Self::add_scope()`] for details.
3498 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementGetCall<'a, C>
3499 where
3500 I: IntoIterator<Item = St>,
3501 St: AsRef<str>,
3502 {
3503 self._scopes
3504 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3505 self
3506 }
3507
3508 /// Removes all scopes, and no default scope will be used either.
3509 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3510 /// for details).
3511 pub fn clear_scopes(mut self) -> ProviderEntitlementGetCall<'a, C> {
3512 self._scopes.clear();
3513 self
3514 }
3515}
3516
3517/// Lists Entitlements for which the provider has read access.
3518///
3519/// A builder for the *entitlements.list* method supported by a *provider* resource.
3520/// It is not used directly, but through a [`ProviderMethods`] instance.
3521///
3522/// # Example
3523///
3524/// Instantiate a resource method builder
3525///
3526/// ```test_harness,no_run
3527/// # extern crate hyper;
3528/// # extern crate hyper_rustls;
3529/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
3530/// # async fn dox() {
3531/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3532///
3533/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3534/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3535/// # .with_native_roots()
3536/// # .unwrap()
3537/// # .https_only()
3538/// # .enable_http2()
3539/// # .build();
3540///
3541/// # let executor = hyper_util::rt::TokioExecutor::new();
3542/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3543/// # secret,
3544/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3545/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3546/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3547/// # ),
3548/// # ).build().await.unwrap();
3549///
3550/// # let client = hyper_util::client::legacy::Client::builder(
3551/// # hyper_util::rt::TokioExecutor::new()
3552/// # )
3553/// # .build(
3554/// # hyper_rustls::HttpsConnectorBuilder::new()
3555/// # .with_native_roots()
3556/// # .unwrap()
3557/// # .https_or_http()
3558/// # .enable_http2()
3559/// # .build()
3560/// # );
3561/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
3562/// // You can configure optional parameters by calling the respective setters at will, and
3563/// // execute the final call using `doit()`.
3564/// // Values shown here are possibly random and not representative !
3565/// let result = hub.providers().entitlements_list("parent")
3566/// .page_token("gubergren")
3567/// .page_size(-75)
3568/// .filter("dolor")
3569/// .doit().await;
3570/// # }
3571/// ```
3572pub struct ProviderEntitlementListCall<'a, C>
3573where
3574 C: 'a,
3575{
3576 hub: &'a CloudCommercePartnerProcurementService<C>,
3577 _parent: String,
3578 _page_token: Option<String>,
3579 _page_size: Option<i32>,
3580 _filter: Option<String>,
3581 _delegate: Option<&'a mut dyn common::Delegate>,
3582 _additional_params: HashMap<String, String>,
3583 _scopes: BTreeSet<String>,
3584}
3585
3586impl<'a, C> common::CallBuilder for ProviderEntitlementListCall<'a, C> {}
3587
3588impl<'a, C> ProviderEntitlementListCall<'a, C>
3589where
3590 C: common::Connector,
3591{
3592 /// Perform the operation you have build so far.
3593 pub async fn doit(mut self) -> common::Result<(common::Response, ListEntitlementsResponse)> {
3594 use std::borrow::Cow;
3595 use std::io::{Read, Seek};
3596
3597 use common::{url::Params, ToParts};
3598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3599
3600 let mut dd = common::DefaultDelegate;
3601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3602 dlg.begin(common::MethodInfo {
3603 id: "cloudcommerceprocurement.providers.entitlements.list",
3604 http_method: hyper::Method::GET,
3605 });
3606
3607 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
3608 if self._additional_params.contains_key(field) {
3609 dlg.finished(false);
3610 return Err(common::Error::FieldClash(field));
3611 }
3612 }
3613
3614 let mut params = Params::with_capacity(6 + self._additional_params.len());
3615 params.push("parent", self._parent);
3616 if let Some(value) = self._page_token.as_ref() {
3617 params.push("pageToken", value);
3618 }
3619 if let Some(value) = self._page_size.as_ref() {
3620 params.push("pageSize", value.to_string());
3621 }
3622 if let Some(value) = self._filter.as_ref() {
3623 params.push("filter", value);
3624 }
3625
3626 params.extend(self._additional_params.iter());
3627
3628 params.push("alt", "json");
3629 let mut url = self.hub._base_url.clone() + "v1/{+parent}/entitlements";
3630 if self._scopes.is_empty() {
3631 self._scopes
3632 .insert(Scope::CloudPlatform.as_ref().to_string());
3633 }
3634
3635 #[allow(clippy::single_element_loop)]
3636 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3637 url = params.uri_replacement(url, param_name, find_this, true);
3638 }
3639 {
3640 let to_remove = ["parent"];
3641 params.remove_params(&to_remove);
3642 }
3643
3644 let url = params.parse_with_url(&url);
3645
3646 loop {
3647 let token = match self
3648 .hub
3649 .auth
3650 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3651 .await
3652 {
3653 Ok(token) => token,
3654 Err(e) => match dlg.token(e) {
3655 Ok(token) => token,
3656 Err(e) => {
3657 dlg.finished(false);
3658 return Err(common::Error::MissingToken(e));
3659 }
3660 },
3661 };
3662 let mut req_result = {
3663 let client = &self.hub.client;
3664 dlg.pre_request();
3665 let mut req_builder = hyper::Request::builder()
3666 .method(hyper::Method::GET)
3667 .uri(url.as_str())
3668 .header(USER_AGENT, self.hub._user_agent.clone());
3669
3670 if let Some(token) = token.as_ref() {
3671 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3672 }
3673
3674 let request = req_builder
3675 .header(CONTENT_LENGTH, 0_u64)
3676 .body(common::to_body::<String>(None));
3677
3678 client.request(request.unwrap()).await
3679 };
3680
3681 match req_result {
3682 Err(err) => {
3683 if let common::Retry::After(d) = dlg.http_error(&err) {
3684 sleep(d).await;
3685 continue;
3686 }
3687 dlg.finished(false);
3688 return Err(common::Error::HttpError(err));
3689 }
3690 Ok(res) => {
3691 let (mut parts, body) = res.into_parts();
3692 let mut body = common::Body::new(body);
3693 if !parts.status.is_success() {
3694 let bytes = common::to_bytes(body).await.unwrap_or_default();
3695 let error = serde_json::from_str(&common::to_string(&bytes));
3696 let response = common::to_response(parts, bytes.into());
3697
3698 if let common::Retry::After(d) =
3699 dlg.http_failure(&response, error.as_ref().ok())
3700 {
3701 sleep(d).await;
3702 continue;
3703 }
3704
3705 dlg.finished(false);
3706
3707 return Err(match error {
3708 Ok(value) => common::Error::BadRequest(value),
3709 _ => common::Error::Failure(response),
3710 });
3711 }
3712 let response = {
3713 let bytes = common::to_bytes(body).await.unwrap_or_default();
3714 let encoded = common::to_string(&bytes);
3715 match serde_json::from_str(&encoded) {
3716 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3717 Err(error) => {
3718 dlg.response_json_decode_error(&encoded, &error);
3719 return Err(common::Error::JsonDecodeError(
3720 encoded.to_string(),
3721 error,
3722 ));
3723 }
3724 }
3725 };
3726
3727 dlg.finished(true);
3728 return Ok(response);
3729 }
3730 }
3731 }
3732 }
3733
3734 /// Required. The parent resource name.
3735 ///
3736 /// Sets the *parent* path property to the given value.
3737 ///
3738 /// Even though the property as already been set when instantiating this call,
3739 /// we provide this method for API completeness.
3740 pub fn parent(mut self, new_value: &str) -> ProviderEntitlementListCall<'a, C> {
3741 self._parent = new_value.to_string();
3742 self
3743 }
3744 /// The token for fetching the next page.
3745 ///
3746 /// Sets the *page token* query property to the given value.
3747 pub fn page_token(mut self, new_value: &str) -> ProviderEntitlementListCall<'a, C> {
3748 self._page_token = Some(new_value.to_string());
3749 self
3750 }
3751 /// The maximum number of entries that are requested. The default page size is 200.
3752 ///
3753 /// Sets the *page size* query property to the given value.
3754 pub fn page_size(mut self, new_value: i32) -> ProviderEntitlementListCall<'a, C> {
3755 self._page_size = Some(new_value);
3756 self
3757 }
3758 /// The filter that can be used to limit the list request. The filter is a query string that can match a selected set of attributes with string values. For example `account=E-1234-5678-ABCD-EFGH`, `state=pending_cancellation`, and `plan!=foo-plan`. Supported query attributes are * `account` * `customer_billing_account` with value in the format of: `billingAccounts/{id}` * `product_external_name` * `quote_external_name` * `offer` * `new_pending_offer` * `plan` * `newPendingPlan` or `new_pending_plan` * `state` * `services` * `consumers.project` * `change_history.new_offer` Note that the consumers and change_history.new_offer match works on repeated structures, so equality (`consumers.project=projects/123456789`) is not supported. Set membership can be expressed with the `:` operator. For example, `consumers.project:projects/123456789` finds entitlements with at least one consumer with project field equal to `projects/123456789`. `change_history.new_offer` retrieves all entitlements that were once associated or are currently active with the offer. Also note that the state name match is case-insensitive and query can omit the prefix "ENTITLEMENT_". For example, `state=active` is equivalent to `state=ENTITLEMENT_ACTIVE`. If the query contains some special characters other than letters, underscore, or digits, the phrase must be quoted with double quotes. For example, `product="providerId:productId"`, where the product name needs to be quoted because it contains special character colon. Queries can be combined with `AND`, `OR`, and `NOT` to form more complex queries. They can also be grouped to force a desired evaluation order. For example, `state=active AND (account=E-1234 OR account=5678) AND NOT (product=foo-product)`. Connective `AND` can be omitted between two predicates. For example `account=E-1234 state=active` is equivalent to `account=E-1234 AND state=active`.
3759 ///
3760 /// Sets the *filter* query property to the given value.
3761 pub fn filter(mut self, new_value: &str) -> ProviderEntitlementListCall<'a, C> {
3762 self._filter = Some(new_value.to_string());
3763 self
3764 }
3765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3766 /// while executing the actual API request.
3767 ///
3768 /// ````text
3769 /// It should be used to handle progress information, and to implement a certain level of resilience.
3770 /// ````
3771 ///
3772 /// Sets the *delegate* property to the given value.
3773 pub fn delegate(
3774 mut self,
3775 new_value: &'a mut dyn common::Delegate,
3776 ) -> ProviderEntitlementListCall<'a, C> {
3777 self._delegate = Some(new_value);
3778 self
3779 }
3780
3781 /// Set any additional parameter of the query string used in the request.
3782 /// It should be used to set parameters which are not yet available through their own
3783 /// setters.
3784 ///
3785 /// Please note that this method must not be used to set any of the known parameters
3786 /// which have their own setter method. If done anyway, the request will fail.
3787 ///
3788 /// # Additional Parameters
3789 ///
3790 /// * *$.xgafv* (query-string) - V1 error format.
3791 /// * *access_token* (query-string) - OAuth access token.
3792 /// * *alt* (query-string) - Data format for response.
3793 /// * *callback* (query-string) - JSONP
3794 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3795 /// * *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.
3796 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3797 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3798 /// * *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.
3799 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3800 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3801 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementListCall<'a, C>
3802 where
3803 T: AsRef<str>,
3804 {
3805 self._additional_params
3806 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3807 self
3808 }
3809
3810 /// Identifies the authorization scope for the method you are building.
3811 ///
3812 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3813 /// [`Scope::CloudPlatform`].
3814 ///
3815 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3816 /// tokens for more than one scope.
3817 ///
3818 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3819 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3820 /// sufficient, a read-write scope will do as well.
3821 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementListCall<'a, C>
3822 where
3823 St: AsRef<str>,
3824 {
3825 self._scopes.insert(String::from(scope.as_ref()));
3826 self
3827 }
3828 /// Identifies the authorization scope(s) for the method you are building.
3829 ///
3830 /// See [`Self::add_scope()`] for details.
3831 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementListCall<'a, C>
3832 where
3833 I: IntoIterator<Item = St>,
3834 St: AsRef<str>,
3835 {
3836 self._scopes
3837 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3838 self
3839 }
3840
3841 /// Removes all scopes, and no default scope will be used either.
3842 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3843 /// for details).
3844 pub fn clear_scopes(mut self) -> ProviderEntitlementListCall<'a, C> {
3845 self._scopes.clear();
3846 self
3847 }
3848}
3849
3850/// Updates an existing Entitlement.
3851///
3852/// A builder for the *entitlements.patch* method supported by a *provider* resource.
3853/// It is not used directly, but through a [`ProviderMethods`] instance.
3854///
3855/// # Example
3856///
3857/// Instantiate a resource method builder
3858///
3859/// ```test_harness,no_run
3860/// # extern crate hyper;
3861/// # extern crate hyper_rustls;
3862/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
3863/// use cloudcommerceprocurement1::api::Entitlement;
3864/// # async fn dox() {
3865/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3866///
3867/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3868/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3869/// # .with_native_roots()
3870/// # .unwrap()
3871/// # .https_only()
3872/// # .enable_http2()
3873/// # .build();
3874///
3875/// # let executor = hyper_util::rt::TokioExecutor::new();
3876/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3877/// # secret,
3878/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3879/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3880/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3881/// # ),
3882/// # ).build().await.unwrap();
3883///
3884/// # let client = hyper_util::client::legacy::Client::builder(
3885/// # hyper_util::rt::TokioExecutor::new()
3886/// # )
3887/// # .build(
3888/// # hyper_rustls::HttpsConnectorBuilder::new()
3889/// # .with_native_roots()
3890/// # .unwrap()
3891/// # .https_or_http()
3892/// # .enable_http2()
3893/// # .build()
3894/// # );
3895/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
3896/// // As the method needs a request, you would usually fill it with the desired information
3897/// // into the respective structure. Some of the parts shown here might not be applicable !
3898/// // Values shown here are possibly random and not representative !
3899/// let mut req = Entitlement::default();
3900///
3901/// // You can configure optional parameters by calling the respective setters at will, and
3902/// // execute the final call using `doit()`.
3903/// // Values shown here are possibly random and not representative !
3904/// let result = hub.providers().entitlements_patch(req, "name")
3905/// .update_mask(FieldMask::new::<&str>(&[]))
3906/// .doit().await;
3907/// # }
3908/// ```
3909pub struct ProviderEntitlementPatchCall<'a, C>
3910where
3911 C: 'a,
3912{
3913 hub: &'a CloudCommercePartnerProcurementService<C>,
3914 _request: Entitlement,
3915 _name: String,
3916 _update_mask: Option<common::FieldMask>,
3917 _delegate: Option<&'a mut dyn common::Delegate>,
3918 _additional_params: HashMap<String, String>,
3919 _scopes: BTreeSet<String>,
3920}
3921
3922impl<'a, C> common::CallBuilder for ProviderEntitlementPatchCall<'a, C> {}
3923
3924impl<'a, C> ProviderEntitlementPatchCall<'a, C>
3925where
3926 C: common::Connector,
3927{
3928 /// Perform the operation you have build so far.
3929 pub async fn doit(mut self) -> common::Result<(common::Response, Entitlement)> {
3930 use std::borrow::Cow;
3931 use std::io::{Read, Seek};
3932
3933 use common::{url::Params, ToParts};
3934 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3935
3936 let mut dd = common::DefaultDelegate;
3937 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3938 dlg.begin(common::MethodInfo {
3939 id: "cloudcommerceprocurement.providers.entitlements.patch",
3940 http_method: hyper::Method::PATCH,
3941 });
3942
3943 for &field in ["alt", "name", "updateMask"].iter() {
3944 if self._additional_params.contains_key(field) {
3945 dlg.finished(false);
3946 return Err(common::Error::FieldClash(field));
3947 }
3948 }
3949
3950 let mut params = Params::with_capacity(5 + self._additional_params.len());
3951 params.push("name", self._name);
3952 if let Some(value) = self._update_mask.as_ref() {
3953 params.push("updateMask", value.to_string());
3954 }
3955
3956 params.extend(self._additional_params.iter());
3957
3958 params.push("alt", "json");
3959 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3960 if self._scopes.is_empty() {
3961 self._scopes
3962 .insert(Scope::CloudPlatform.as_ref().to_string());
3963 }
3964
3965 #[allow(clippy::single_element_loop)]
3966 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3967 url = params.uri_replacement(url, param_name, find_this, true);
3968 }
3969 {
3970 let to_remove = ["name"];
3971 params.remove_params(&to_remove);
3972 }
3973
3974 let url = params.parse_with_url(&url);
3975
3976 let mut json_mime_type = mime::APPLICATION_JSON;
3977 let mut request_value_reader = {
3978 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3979 common::remove_json_null_values(&mut value);
3980 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3981 serde_json::to_writer(&mut dst, &value).unwrap();
3982 dst
3983 };
3984 let request_size = request_value_reader
3985 .seek(std::io::SeekFrom::End(0))
3986 .unwrap();
3987 request_value_reader
3988 .seek(std::io::SeekFrom::Start(0))
3989 .unwrap();
3990
3991 loop {
3992 let token = match self
3993 .hub
3994 .auth
3995 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3996 .await
3997 {
3998 Ok(token) => token,
3999 Err(e) => match dlg.token(e) {
4000 Ok(token) => token,
4001 Err(e) => {
4002 dlg.finished(false);
4003 return Err(common::Error::MissingToken(e));
4004 }
4005 },
4006 };
4007 request_value_reader
4008 .seek(std::io::SeekFrom::Start(0))
4009 .unwrap();
4010 let mut req_result = {
4011 let client = &self.hub.client;
4012 dlg.pre_request();
4013 let mut req_builder = hyper::Request::builder()
4014 .method(hyper::Method::PATCH)
4015 .uri(url.as_str())
4016 .header(USER_AGENT, self.hub._user_agent.clone());
4017
4018 if let Some(token) = token.as_ref() {
4019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4020 }
4021
4022 let request = req_builder
4023 .header(CONTENT_TYPE, json_mime_type.to_string())
4024 .header(CONTENT_LENGTH, request_size as u64)
4025 .body(common::to_body(
4026 request_value_reader.get_ref().clone().into(),
4027 ));
4028
4029 client.request(request.unwrap()).await
4030 };
4031
4032 match req_result {
4033 Err(err) => {
4034 if let common::Retry::After(d) = dlg.http_error(&err) {
4035 sleep(d).await;
4036 continue;
4037 }
4038 dlg.finished(false);
4039 return Err(common::Error::HttpError(err));
4040 }
4041 Ok(res) => {
4042 let (mut parts, body) = res.into_parts();
4043 let mut body = common::Body::new(body);
4044 if !parts.status.is_success() {
4045 let bytes = common::to_bytes(body).await.unwrap_or_default();
4046 let error = serde_json::from_str(&common::to_string(&bytes));
4047 let response = common::to_response(parts, bytes.into());
4048
4049 if let common::Retry::After(d) =
4050 dlg.http_failure(&response, error.as_ref().ok())
4051 {
4052 sleep(d).await;
4053 continue;
4054 }
4055
4056 dlg.finished(false);
4057
4058 return Err(match error {
4059 Ok(value) => common::Error::BadRequest(value),
4060 _ => common::Error::Failure(response),
4061 });
4062 }
4063 let response = {
4064 let bytes = common::to_bytes(body).await.unwrap_or_default();
4065 let encoded = common::to_string(&bytes);
4066 match serde_json::from_str(&encoded) {
4067 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4068 Err(error) => {
4069 dlg.response_json_decode_error(&encoded, &error);
4070 return Err(common::Error::JsonDecodeError(
4071 encoded.to_string(),
4072 error,
4073 ));
4074 }
4075 }
4076 };
4077
4078 dlg.finished(true);
4079 return Ok(response);
4080 }
4081 }
4082 }
4083 }
4084
4085 ///
4086 /// Sets the *request* property to the given value.
4087 ///
4088 /// Even though the property as already been set when instantiating this call,
4089 /// we provide this method for API completeness.
4090 pub fn request(mut self, new_value: Entitlement) -> ProviderEntitlementPatchCall<'a, C> {
4091 self._request = new_value;
4092 self
4093 }
4094 /// Required. The name of the entitlement to update.
4095 ///
4096 /// Sets the *name* path property to the given value.
4097 ///
4098 /// Even though the property as already been set when instantiating this call,
4099 /// we provide this method for API completeness.
4100 pub fn name(mut self, new_value: &str) -> ProviderEntitlementPatchCall<'a, C> {
4101 self._name = new_value.to_string();
4102 self
4103 }
4104 /// The update mask that applies to the resource. See the [FieldMask definition] (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask) for more details.
4105 ///
4106 /// Sets the *update mask* query property to the given value.
4107 pub fn update_mask(
4108 mut self,
4109 new_value: common::FieldMask,
4110 ) -> ProviderEntitlementPatchCall<'a, C> {
4111 self._update_mask = Some(new_value);
4112 self
4113 }
4114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4115 /// while executing the actual API request.
4116 ///
4117 /// ````text
4118 /// It should be used to handle progress information, and to implement a certain level of resilience.
4119 /// ````
4120 ///
4121 /// Sets the *delegate* property to the given value.
4122 pub fn delegate(
4123 mut self,
4124 new_value: &'a mut dyn common::Delegate,
4125 ) -> ProviderEntitlementPatchCall<'a, C> {
4126 self._delegate = Some(new_value);
4127 self
4128 }
4129
4130 /// Set any additional parameter of the query string used in the request.
4131 /// It should be used to set parameters which are not yet available through their own
4132 /// setters.
4133 ///
4134 /// Please note that this method must not be used to set any of the known parameters
4135 /// which have their own setter method. If done anyway, the request will fail.
4136 ///
4137 /// # Additional Parameters
4138 ///
4139 /// * *$.xgafv* (query-string) - V1 error format.
4140 /// * *access_token* (query-string) - OAuth access token.
4141 /// * *alt* (query-string) - Data format for response.
4142 /// * *callback* (query-string) - JSONP
4143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4144 /// * *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.
4145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4147 /// * *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.
4148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4150 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementPatchCall<'a, C>
4151 where
4152 T: AsRef<str>,
4153 {
4154 self._additional_params
4155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4156 self
4157 }
4158
4159 /// Identifies the authorization scope for the method you are building.
4160 ///
4161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4162 /// [`Scope::CloudPlatform`].
4163 ///
4164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4165 /// tokens for more than one scope.
4166 ///
4167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4169 /// sufficient, a read-write scope will do as well.
4170 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementPatchCall<'a, C>
4171 where
4172 St: AsRef<str>,
4173 {
4174 self._scopes.insert(String::from(scope.as_ref()));
4175 self
4176 }
4177 /// Identifies the authorization scope(s) for the method you are building.
4178 ///
4179 /// See [`Self::add_scope()`] for details.
4180 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementPatchCall<'a, C>
4181 where
4182 I: IntoIterator<Item = St>,
4183 St: AsRef<str>,
4184 {
4185 self._scopes
4186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4187 self
4188 }
4189
4190 /// Removes all scopes, and no default scope will be used either.
4191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4192 /// for details).
4193 pub fn clear_scopes(mut self) -> ProviderEntitlementPatchCall<'a, C> {
4194 self._scopes.clear();
4195 self
4196 }
4197}
4198
4199/// Rejects an entitlement that is in the EntitlementState.ENTITLEMENT_ACTIVATION_REQUESTED state. This method is invoked by the provider to reject the creation of the entitlement resource.
4200///
4201/// A builder for the *entitlements.reject* method supported by a *provider* resource.
4202/// It is not used directly, but through a [`ProviderMethods`] instance.
4203///
4204/// # Example
4205///
4206/// Instantiate a resource method builder
4207///
4208/// ```test_harness,no_run
4209/// # extern crate hyper;
4210/// # extern crate hyper_rustls;
4211/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
4212/// use cloudcommerceprocurement1::api::RejectEntitlementRequest;
4213/// # async fn dox() {
4214/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4215///
4216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4218/// # .with_native_roots()
4219/// # .unwrap()
4220/// # .https_only()
4221/// # .enable_http2()
4222/// # .build();
4223///
4224/// # let executor = hyper_util::rt::TokioExecutor::new();
4225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4226/// # secret,
4227/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4228/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4229/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4230/// # ),
4231/// # ).build().await.unwrap();
4232///
4233/// # let client = hyper_util::client::legacy::Client::builder(
4234/// # hyper_util::rt::TokioExecutor::new()
4235/// # )
4236/// # .build(
4237/// # hyper_rustls::HttpsConnectorBuilder::new()
4238/// # .with_native_roots()
4239/// # .unwrap()
4240/// # .https_or_http()
4241/// # .enable_http2()
4242/// # .build()
4243/// # );
4244/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
4245/// // As the method needs a request, you would usually fill it with the desired information
4246/// // into the respective structure. Some of the parts shown here might not be applicable !
4247/// // Values shown here are possibly random and not representative !
4248/// let mut req = RejectEntitlementRequest::default();
4249///
4250/// // You can configure optional parameters by calling the respective setters at will, and
4251/// // execute the final call using `doit()`.
4252/// // Values shown here are possibly random and not representative !
4253/// let result = hub.providers().entitlements_reject(req, "name")
4254/// .doit().await;
4255/// # }
4256/// ```
4257pub struct ProviderEntitlementRejectCall<'a, C>
4258where
4259 C: 'a,
4260{
4261 hub: &'a CloudCommercePartnerProcurementService<C>,
4262 _request: RejectEntitlementRequest,
4263 _name: String,
4264 _delegate: Option<&'a mut dyn common::Delegate>,
4265 _additional_params: HashMap<String, String>,
4266 _scopes: BTreeSet<String>,
4267}
4268
4269impl<'a, C> common::CallBuilder for ProviderEntitlementRejectCall<'a, C> {}
4270
4271impl<'a, C> ProviderEntitlementRejectCall<'a, C>
4272where
4273 C: common::Connector,
4274{
4275 /// Perform the operation you have build so far.
4276 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4277 use std::borrow::Cow;
4278 use std::io::{Read, Seek};
4279
4280 use common::{url::Params, ToParts};
4281 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4282
4283 let mut dd = common::DefaultDelegate;
4284 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4285 dlg.begin(common::MethodInfo {
4286 id: "cloudcommerceprocurement.providers.entitlements.reject",
4287 http_method: hyper::Method::POST,
4288 });
4289
4290 for &field in ["alt", "name"].iter() {
4291 if self._additional_params.contains_key(field) {
4292 dlg.finished(false);
4293 return Err(common::Error::FieldClash(field));
4294 }
4295 }
4296
4297 let mut params = Params::with_capacity(4 + self._additional_params.len());
4298 params.push("name", self._name);
4299
4300 params.extend(self._additional_params.iter());
4301
4302 params.push("alt", "json");
4303 let mut url = self.hub._base_url.clone() + "v1/{+name}:reject";
4304 if self._scopes.is_empty() {
4305 self._scopes
4306 .insert(Scope::CloudPlatform.as_ref().to_string());
4307 }
4308
4309 #[allow(clippy::single_element_loop)]
4310 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4311 url = params.uri_replacement(url, param_name, find_this, true);
4312 }
4313 {
4314 let to_remove = ["name"];
4315 params.remove_params(&to_remove);
4316 }
4317
4318 let url = params.parse_with_url(&url);
4319
4320 let mut json_mime_type = mime::APPLICATION_JSON;
4321 let mut request_value_reader = {
4322 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4323 common::remove_json_null_values(&mut value);
4324 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4325 serde_json::to_writer(&mut dst, &value).unwrap();
4326 dst
4327 };
4328 let request_size = request_value_reader
4329 .seek(std::io::SeekFrom::End(0))
4330 .unwrap();
4331 request_value_reader
4332 .seek(std::io::SeekFrom::Start(0))
4333 .unwrap();
4334
4335 loop {
4336 let token = match self
4337 .hub
4338 .auth
4339 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4340 .await
4341 {
4342 Ok(token) => token,
4343 Err(e) => match dlg.token(e) {
4344 Ok(token) => token,
4345 Err(e) => {
4346 dlg.finished(false);
4347 return Err(common::Error::MissingToken(e));
4348 }
4349 },
4350 };
4351 request_value_reader
4352 .seek(std::io::SeekFrom::Start(0))
4353 .unwrap();
4354 let mut req_result = {
4355 let client = &self.hub.client;
4356 dlg.pre_request();
4357 let mut req_builder = hyper::Request::builder()
4358 .method(hyper::Method::POST)
4359 .uri(url.as_str())
4360 .header(USER_AGENT, self.hub._user_agent.clone());
4361
4362 if let Some(token) = token.as_ref() {
4363 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4364 }
4365
4366 let request = req_builder
4367 .header(CONTENT_TYPE, json_mime_type.to_string())
4368 .header(CONTENT_LENGTH, request_size as u64)
4369 .body(common::to_body(
4370 request_value_reader.get_ref().clone().into(),
4371 ));
4372
4373 client.request(request.unwrap()).await
4374 };
4375
4376 match req_result {
4377 Err(err) => {
4378 if let common::Retry::After(d) = dlg.http_error(&err) {
4379 sleep(d).await;
4380 continue;
4381 }
4382 dlg.finished(false);
4383 return Err(common::Error::HttpError(err));
4384 }
4385 Ok(res) => {
4386 let (mut parts, body) = res.into_parts();
4387 let mut body = common::Body::new(body);
4388 if !parts.status.is_success() {
4389 let bytes = common::to_bytes(body).await.unwrap_or_default();
4390 let error = serde_json::from_str(&common::to_string(&bytes));
4391 let response = common::to_response(parts, bytes.into());
4392
4393 if let common::Retry::After(d) =
4394 dlg.http_failure(&response, error.as_ref().ok())
4395 {
4396 sleep(d).await;
4397 continue;
4398 }
4399
4400 dlg.finished(false);
4401
4402 return Err(match error {
4403 Ok(value) => common::Error::BadRequest(value),
4404 _ => common::Error::Failure(response),
4405 });
4406 }
4407 let response = {
4408 let bytes = common::to_bytes(body).await.unwrap_or_default();
4409 let encoded = common::to_string(&bytes);
4410 match serde_json::from_str(&encoded) {
4411 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4412 Err(error) => {
4413 dlg.response_json_decode_error(&encoded, &error);
4414 return Err(common::Error::JsonDecodeError(
4415 encoded.to_string(),
4416 error,
4417 ));
4418 }
4419 }
4420 };
4421
4422 dlg.finished(true);
4423 return Ok(response);
4424 }
4425 }
4426 }
4427 }
4428
4429 ///
4430 /// Sets the *request* property to the given value.
4431 ///
4432 /// Even though the property as already been set when instantiating this call,
4433 /// we provide this method for API completeness.
4434 pub fn request(
4435 mut self,
4436 new_value: RejectEntitlementRequest,
4437 ) -> ProviderEntitlementRejectCall<'a, C> {
4438 self._request = new_value;
4439 self
4440 }
4441 /// Required. The resource name of the entitlement.
4442 ///
4443 /// Sets the *name* path property to the given value.
4444 ///
4445 /// Even though the property as already been set when instantiating this call,
4446 /// we provide this method for API completeness.
4447 pub fn name(mut self, new_value: &str) -> ProviderEntitlementRejectCall<'a, C> {
4448 self._name = new_value.to_string();
4449 self
4450 }
4451 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4452 /// while executing the actual API request.
4453 ///
4454 /// ````text
4455 /// It should be used to handle progress information, and to implement a certain level of resilience.
4456 /// ````
4457 ///
4458 /// Sets the *delegate* property to the given value.
4459 pub fn delegate(
4460 mut self,
4461 new_value: &'a mut dyn common::Delegate,
4462 ) -> ProviderEntitlementRejectCall<'a, C> {
4463 self._delegate = Some(new_value);
4464 self
4465 }
4466
4467 /// Set any additional parameter of the query string used in the request.
4468 /// It should be used to set parameters which are not yet available through their own
4469 /// setters.
4470 ///
4471 /// Please note that this method must not be used to set any of the known parameters
4472 /// which have their own setter method. If done anyway, the request will fail.
4473 ///
4474 /// # Additional Parameters
4475 ///
4476 /// * *$.xgafv* (query-string) - V1 error format.
4477 /// * *access_token* (query-string) - OAuth access token.
4478 /// * *alt* (query-string) - Data format for response.
4479 /// * *callback* (query-string) - JSONP
4480 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4481 /// * *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.
4482 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4483 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4484 /// * *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.
4485 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4486 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4487 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementRejectCall<'a, C>
4488 where
4489 T: AsRef<str>,
4490 {
4491 self._additional_params
4492 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4493 self
4494 }
4495
4496 /// Identifies the authorization scope for the method you are building.
4497 ///
4498 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4499 /// [`Scope::CloudPlatform`].
4500 ///
4501 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4502 /// tokens for more than one scope.
4503 ///
4504 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4505 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4506 /// sufficient, a read-write scope will do as well.
4507 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementRejectCall<'a, C>
4508 where
4509 St: AsRef<str>,
4510 {
4511 self._scopes.insert(String::from(scope.as_ref()));
4512 self
4513 }
4514 /// Identifies the authorization scope(s) for the method you are building.
4515 ///
4516 /// See [`Self::add_scope()`] for details.
4517 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementRejectCall<'a, C>
4518 where
4519 I: IntoIterator<Item = St>,
4520 St: AsRef<str>,
4521 {
4522 self._scopes
4523 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4524 self
4525 }
4526
4527 /// Removes all scopes, and no default scope will be used either.
4528 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4529 /// for details).
4530 pub fn clear_scopes(mut self) -> ProviderEntitlementRejectCall<'a, C> {
4531 self._scopes.clear();
4532 self
4533 }
4534}
4535
4536/// Rejects an entitlement plan change that is in the EntitlementState.ENTITLEMENT_PENDING_PLAN_CHANGE_APPROVAL state. This method is invoked by the provider to reject the plan change on the entitlement resource.
4537///
4538/// A builder for the *entitlements.rejectPlanChange* method supported by a *provider* resource.
4539/// It is not used directly, but through a [`ProviderMethods`] instance.
4540///
4541/// # Example
4542///
4543/// Instantiate a resource method builder
4544///
4545/// ```test_harness,no_run
4546/// # extern crate hyper;
4547/// # extern crate hyper_rustls;
4548/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
4549/// use cloudcommerceprocurement1::api::RejectEntitlementPlanChangeRequest;
4550/// # async fn dox() {
4551/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4552///
4553/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4554/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4555/// # .with_native_roots()
4556/// # .unwrap()
4557/// # .https_only()
4558/// # .enable_http2()
4559/// # .build();
4560///
4561/// # let executor = hyper_util::rt::TokioExecutor::new();
4562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4563/// # secret,
4564/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4565/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4566/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4567/// # ),
4568/// # ).build().await.unwrap();
4569///
4570/// # let client = hyper_util::client::legacy::Client::builder(
4571/// # hyper_util::rt::TokioExecutor::new()
4572/// # )
4573/// # .build(
4574/// # hyper_rustls::HttpsConnectorBuilder::new()
4575/// # .with_native_roots()
4576/// # .unwrap()
4577/// # .https_or_http()
4578/// # .enable_http2()
4579/// # .build()
4580/// # );
4581/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
4582/// // As the method needs a request, you would usually fill it with the desired information
4583/// // into the respective structure. Some of the parts shown here might not be applicable !
4584/// // Values shown here are possibly random and not representative !
4585/// let mut req = RejectEntitlementPlanChangeRequest::default();
4586///
4587/// // You can configure optional parameters by calling the respective setters at will, and
4588/// // execute the final call using `doit()`.
4589/// // Values shown here are possibly random and not representative !
4590/// let result = hub.providers().entitlements_reject_plan_change(req, "name")
4591/// .doit().await;
4592/// # }
4593/// ```
4594pub struct ProviderEntitlementRejectPlanChangeCall<'a, C>
4595where
4596 C: 'a,
4597{
4598 hub: &'a CloudCommercePartnerProcurementService<C>,
4599 _request: RejectEntitlementPlanChangeRequest,
4600 _name: String,
4601 _delegate: Option<&'a mut dyn common::Delegate>,
4602 _additional_params: HashMap<String, String>,
4603 _scopes: BTreeSet<String>,
4604}
4605
4606impl<'a, C> common::CallBuilder for ProviderEntitlementRejectPlanChangeCall<'a, C> {}
4607
4608impl<'a, C> ProviderEntitlementRejectPlanChangeCall<'a, C>
4609where
4610 C: common::Connector,
4611{
4612 /// Perform the operation you have build so far.
4613 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4614 use std::borrow::Cow;
4615 use std::io::{Read, Seek};
4616
4617 use common::{url::Params, ToParts};
4618 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4619
4620 let mut dd = common::DefaultDelegate;
4621 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4622 dlg.begin(common::MethodInfo {
4623 id: "cloudcommerceprocurement.providers.entitlements.rejectPlanChange",
4624 http_method: hyper::Method::POST,
4625 });
4626
4627 for &field in ["alt", "name"].iter() {
4628 if self._additional_params.contains_key(field) {
4629 dlg.finished(false);
4630 return Err(common::Error::FieldClash(field));
4631 }
4632 }
4633
4634 let mut params = Params::with_capacity(4 + self._additional_params.len());
4635 params.push("name", self._name);
4636
4637 params.extend(self._additional_params.iter());
4638
4639 params.push("alt", "json");
4640 let mut url = self.hub._base_url.clone() + "v1/{+name}:rejectPlanChange";
4641 if self._scopes.is_empty() {
4642 self._scopes
4643 .insert(Scope::CloudPlatform.as_ref().to_string());
4644 }
4645
4646 #[allow(clippy::single_element_loop)]
4647 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4648 url = params.uri_replacement(url, param_name, find_this, true);
4649 }
4650 {
4651 let to_remove = ["name"];
4652 params.remove_params(&to_remove);
4653 }
4654
4655 let url = params.parse_with_url(&url);
4656
4657 let mut json_mime_type = mime::APPLICATION_JSON;
4658 let mut request_value_reader = {
4659 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4660 common::remove_json_null_values(&mut value);
4661 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4662 serde_json::to_writer(&mut dst, &value).unwrap();
4663 dst
4664 };
4665 let request_size = request_value_reader
4666 .seek(std::io::SeekFrom::End(0))
4667 .unwrap();
4668 request_value_reader
4669 .seek(std::io::SeekFrom::Start(0))
4670 .unwrap();
4671
4672 loop {
4673 let token = match self
4674 .hub
4675 .auth
4676 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4677 .await
4678 {
4679 Ok(token) => token,
4680 Err(e) => match dlg.token(e) {
4681 Ok(token) => token,
4682 Err(e) => {
4683 dlg.finished(false);
4684 return Err(common::Error::MissingToken(e));
4685 }
4686 },
4687 };
4688 request_value_reader
4689 .seek(std::io::SeekFrom::Start(0))
4690 .unwrap();
4691 let mut req_result = {
4692 let client = &self.hub.client;
4693 dlg.pre_request();
4694 let mut req_builder = hyper::Request::builder()
4695 .method(hyper::Method::POST)
4696 .uri(url.as_str())
4697 .header(USER_AGENT, self.hub._user_agent.clone());
4698
4699 if let Some(token) = token.as_ref() {
4700 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4701 }
4702
4703 let request = req_builder
4704 .header(CONTENT_TYPE, json_mime_type.to_string())
4705 .header(CONTENT_LENGTH, request_size as u64)
4706 .body(common::to_body(
4707 request_value_reader.get_ref().clone().into(),
4708 ));
4709
4710 client.request(request.unwrap()).await
4711 };
4712
4713 match req_result {
4714 Err(err) => {
4715 if let common::Retry::After(d) = dlg.http_error(&err) {
4716 sleep(d).await;
4717 continue;
4718 }
4719 dlg.finished(false);
4720 return Err(common::Error::HttpError(err));
4721 }
4722 Ok(res) => {
4723 let (mut parts, body) = res.into_parts();
4724 let mut body = common::Body::new(body);
4725 if !parts.status.is_success() {
4726 let bytes = common::to_bytes(body).await.unwrap_or_default();
4727 let error = serde_json::from_str(&common::to_string(&bytes));
4728 let response = common::to_response(parts, bytes.into());
4729
4730 if let common::Retry::After(d) =
4731 dlg.http_failure(&response, error.as_ref().ok())
4732 {
4733 sleep(d).await;
4734 continue;
4735 }
4736
4737 dlg.finished(false);
4738
4739 return Err(match error {
4740 Ok(value) => common::Error::BadRequest(value),
4741 _ => common::Error::Failure(response),
4742 });
4743 }
4744 let response = {
4745 let bytes = common::to_bytes(body).await.unwrap_or_default();
4746 let encoded = common::to_string(&bytes);
4747 match serde_json::from_str(&encoded) {
4748 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4749 Err(error) => {
4750 dlg.response_json_decode_error(&encoded, &error);
4751 return Err(common::Error::JsonDecodeError(
4752 encoded.to_string(),
4753 error,
4754 ));
4755 }
4756 }
4757 };
4758
4759 dlg.finished(true);
4760 return Ok(response);
4761 }
4762 }
4763 }
4764 }
4765
4766 ///
4767 /// Sets the *request* property to the given value.
4768 ///
4769 /// Even though the property as already been set when instantiating this call,
4770 /// we provide this method for API completeness.
4771 pub fn request(
4772 mut self,
4773 new_value: RejectEntitlementPlanChangeRequest,
4774 ) -> ProviderEntitlementRejectPlanChangeCall<'a, C> {
4775 self._request = new_value;
4776 self
4777 }
4778 /// Required. The resource name of the entitlement.
4779 ///
4780 /// Sets the *name* path property to the given value.
4781 ///
4782 /// Even though the property as already been set when instantiating this call,
4783 /// we provide this method for API completeness.
4784 pub fn name(mut self, new_value: &str) -> ProviderEntitlementRejectPlanChangeCall<'a, C> {
4785 self._name = new_value.to_string();
4786 self
4787 }
4788 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4789 /// while executing the actual API request.
4790 ///
4791 /// ````text
4792 /// It should be used to handle progress information, and to implement a certain level of resilience.
4793 /// ````
4794 ///
4795 /// Sets the *delegate* property to the given value.
4796 pub fn delegate(
4797 mut self,
4798 new_value: &'a mut dyn common::Delegate,
4799 ) -> ProviderEntitlementRejectPlanChangeCall<'a, C> {
4800 self._delegate = Some(new_value);
4801 self
4802 }
4803
4804 /// Set any additional parameter of the query string used in the request.
4805 /// It should be used to set parameters which are not yet available through their own
4806 /// setters.
4807 ///
4808 /// Please note that this method must not be used to set any of the known parameters
4809 /// which have their own setter method. If done anyway, the request will fail.
4810 ///
4811 /// # Additional Parameters
4812 ///
4813 /// * *$.xgafv* (query-string) - V1 error format.
4814 /// * *access_token* (query-string) - OAuth access token.
4815 /// * *alt* (query-string) - Data format for response.
4816 /// * *callback* (query-string) - JSONP
4817 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4818 /// * *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.
4819 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4820 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4821 /// * *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.
4822 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4823 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4824 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementRejectPlanChangeCall<'a, C>
4825 where
4826 T: AsRef<str>,
4827 {
4828 self._additional_params
4829 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4830 self
4831 }
4832
4833 /// Identifies the authorization scope for the method you are building.
4834 ///
4835 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4836 /// [`Scope::CloudPlatform`].
4837 ///
4838 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4839 /// tokens for more than one scope.
4840 ///
4841 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4842 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4843 /// sufficient, a read-write scope will do as well.
4844 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementRejectPlanChangeCall<'a, C>
4845 where
4846 St: AsRef<str>,
4847 {
4848 self._scopes.insert(String::from(scope.as_ref()));
4849 self
4850 }
4851 /// Identifies the authorization scope(s) for the method you are building.
4852 ///
4853 /// See [`Self::add_scope()`] for details.
4854 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementRejectPlanChangeCall<'a, C>
4855 where
4856 I: IntoIterator<Item = St>,
4857 St: AsRef<str>,
4858 {
4859 self._scopes
4860 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4861 self
4862 }
4863
4864 /// Removes all scopes, and no default scope will be used either.
4865 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4866 /// for details).
4867 pub fn clear_scopes(mut self) -> ProviderEntitlementRejectPlanChangeCall<'a, C> {
4868 self._scopes.clear();
4869 self
4870 }
4871}
4872
4873/// Requests suspension of an active Entitlement. This is not yet supported.
4874///
4875/// A builder for the *entitlements.suspend* method supported by a *provider* resource.
4876/// It is not used directly, but through a [`ProviderMethods`] instance.
4877///
4878/// # Example
4879///
4880/// Instantiate a resource method builder
4881///
4882/// ```test_harness,no_run
4883/// # extern crate hyper;
4884/// # extern crate hyper_rustls;
4885/// # extern crate google_cloudcommerceprocurement1 as cloudcommerceprocurement1;
4886/// use cloudcommerceprocurement1::api::SuspendEntitlementRequest;
4887/// # async fn dox() {
4888/// # use cloudcommerceprocurement1::{CloudCommercePartnerProcurementService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4889///
4890/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4891/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4892/// # .with_native_roots()
4893/// # .unwrap()
4894/// # .https_only()
4895/// # .enable_http2()
4896/// # .build();
4897///
4898/// # let executor = hyper_util::rt::TokioExecutor::new();
4899/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4900/// # secret,
4901/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4902/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4903/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4904/// # ),
4905/// # ).build().await.unwrap();
4906///
4907/// # let client = hyper_util::client::legacy::Client::builder(
4908/// # hyper_util::rt::TokioExecutor::new()
4909/// # )
4910/// # .build(
4911/// # hyper_rustls::HttpsConnectorBuilder::new()
4912/// # .with_native_roots()
4913/// # .unwrap()
4914/// # .https_or_http()
4915/// # .enable_http2()
4916/// # .build()
4917/// # );
4918/// # let mut hub = CloudCommercePartnerProcurementService::new(client, auth);
4919/// // As the method needs a request, you would usually fill it with the desired information
4920/// // into the respective structure. Some of the parts shown here might not be applicable !
4921/// // Values shown here are possibly random and not representative !
4922/// let mut req = SuspendEntitlementRequest::default();
4923///
4924/// // You can configure optional parameters by calling the respective setters at will, and
4925/// // execute the final call using `doit()`.
4926/// // Values shown here are possibly random and not representative !
4927/// let result = hub.providers().entitlements_suspend(req, "name")
4928/// .doit().await;
4929/// # }
4930/// ```
4931pub struct ProviderEntitlementSuspendCall<'a, C>
4932where
4933 C: 'a,
4934{
4935 hub: &'a CloudCommercePartnerProcurementService<C>,
4936 _request: SuspendEntitlementRequest,
4937 _name: String,
4938 _delegate: Option<&'a mut dyn common::Delegate>,
4939 _additional_params: HashMap<String, String>,
4940 _scopes: BTreeSet<String>,
4941}
4942
4943impl<'a, C> common::CallBuilder for ProviderEntitlementSuspendCall<'a, C> {}
4944
4945impl<'a, C> ProviderEntitlementSuspendCall<'a, C>
4946where
4947 C: common::Connector,
4948{
4949 /// Perform the operation you have build so far.
4950 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4951 use std::borrow::Cow;
4952 use std::io::{Read, Seek};
4953
4954 use common::{url::Params, ToParts};
4955 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4956
4957 let mut dd = common::DefaultDelegate;
4958 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4959 dlg.begin(common::MethodInfo {
4960 id: "cloudcommerceprocurement.providers.entitlements.suspend",
4961 http_method: hyper::Method::POST,
4962 });
4963
4964 for &field in ["alt", "name"].iter() {
4965 if self._additional_params.contains_key(field) {
4966 dlg.finished(false);
4967 return Err(common::Error::FieldClash(field));
4968 }
4969 }
4970
4971 let mut params = Params::with_capacity(4 + self._additional_params.len());
4972 params.push("name", self._name);
4973
4974 params.extend(self._additional_params.iter());
4975
4976 params.push("alt", "json");
4977 let mut url = self.hub._base_url.clone() + "v1/{+name}:suspend";
4978 if self._scopes.is_empty() {
4979 self._scopes
4980 .insert(Scope::CloudPlatform.as_ref().to_string());
4981 }
4982
4983 #[allow(clippy::single_element_loop)]
4984 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4985 url = params.uri_replacement(url, param_name, find_this, true);
4986 }
4987 {
4988 let to_remove = ["name"];
4989 params.remove_params(&to_remove);
4990 }
4991
4992 let url = params.parse_with_url(&url);
4993
4994 let mut json_mime_type = mime::APPLICATION_JSON;
4995 let mut request_value_reader = {
4996 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4997 common::remove_json_null_values(&mut value);
4998 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4999 serde_json::to_writer(&mut dst, &value).unwrap();
5000 dst
5001 };
5002 let request_size = request_value_reader
5003 .seek(std::io::SeekFrom::End(0))
5004 .unwrap();
5005 request_value_reader
5006 .seek(std::io::SeekFrom::Start(0))
5007 .unwrap();
5008
5009 loop {
5010 let token = match self
5011 .hub
5012 .auth
5013 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5014 .await
5015 {
5016 Ok(token) => token,
5017 Err(e) => match dlg.token(e) {
5018 Ok(token) => token,
5019 Err(e) => {
5020 dlg.finished(false);
5021 return Err(common::Error::MissingToken(e));
5022 }
5023 },
5024 };
5025 request_value_reader
5026 .seek(std::io::SeekFrom::Start(0))
5027 .unwrap();
5028 let mut req_result = {
5029 let client = &self.hub.client;
5030 dlg.pre_request();
5031 let mut req_builder = hyper::Request::builder()
5032 .method(hyper::Method::POST)
5033 .uri(url.as_str())
5034 .header(USER_AGENT, self.hub._user_agent.clone());
5035
5036 if let Some(token) = token.as_ref() {
5037 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5038 }
5039
5040 let request = req_builder
5041 .header(CONTENT_TYPE, json_mime_type.to_string())
5042 .header(CONTENT_LENGTH, request_size as u64)
5043 .body(common::to_body(
5044 request_value_reader.get_ref().clone().into(),
5045 ));
5046
5047 client.request(request.unwrap()).await
5048 };
5049
5050 match req_result {
5051 Err(err) => {
5052 if let common::Retry::After(d) = dlg.http_error(&err) {
5053 sleep(d).await;
5054 continue;
5055 }
5056 dlg.finished(false);
5057 return Err(common::Error::HttpError(err));
5058 }
5059 Ok(res) => {
5060 let (mut parts, body) = res.into_parts();
5061 let mut body = common::Body::new(body);
5062 if !parts.status.is_success() {
5063 let bytes = common::to_bytes(body).await.unwrap_or_default();
5064 let error = serde_json::from_str(&common::to_string(&bytes));
5065 let response = common::to_response(parts, bytes.into());
5066
5067 if let common::Retry::After(d) =
5068 dlg.http_failure(&response, error.as_ref().ok())
5069 {
5070 sleep(d).await;
5071 continue;
5072 }
5073
5074 dlg.finished(false);
5075
5076 return Err(match error {
5077 Ok(value) => common::Error::BadRequest(value),
5078 _ => common::Error::Failure(response),
5079 });
5080 }
5081 let response = {
5082 let bytes = common::to_bytes(body).await.unwrap_or_default();
5083 let encoded = common::to_string(&bytes);
5084 match serde_json::from_str(&encoded) {
5085 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5086 Err(error) => {
5087 dlg.response_json_decode_error(&encoded, &error);
5088 return Err(common::Error::JsonDecodeError(
5089 encoded.to_string(),
5090 error,
5091 ));
5092 }
5093 }
5094 };
5095
5096 dlg.finished(true);
5097 return Ok(response);
5098 }
5099 }
5100 }
5101 }
5102
5103 ///
5104 /// Sets the *request* property to the given value.
5105 ///
5106 /// Even though the property as already been set when instantiating this call,
5107 /// we provide this method for API completeness.
5108 pub fn request(
5109 mut self,
5110 new_value: SuspendEntitlementRequest,
5111 ) -> ProviderEntitlementSuspendCall<'a, C> {
5112 self._request = new_value;
5113 self
5114 }
5115 /// Required. The name of the entitlement to suspend.
5116 ///
5117 /// Sets the *name* path property to the given value.
5118 ///
5119 /// Even though the property as already been set when instantiating this call,
5120 /// we provide this method for API completeness.
5121 pub fn name(mut self, new_value: &str) -> ProviderEntitlementSuspendCall<'a, C> {
5122 self._name = new_value.to_string();
5123 self
5124 }
5125 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5126 /// while executing the actual API request.
5127 ///
5128 /// ````text
5129 /// It should be used to handle progress information, and to implement a certain level of resilience.
5130 /// ````
5131 ///
5132 /// Sets the *delegate* property to the given value.
5133 pub fn delegate(
5134 mut self,
5135 new_value: &'a mut dyn common::Delegate,
5136 ) -> ProviderEntitlementSuspendCall<'a, C> {
5137 self._delegate = Some(new_value);
5138 self
5139 }
5140
5141 /// Set any additional parameter of the query string used in the request.
5142 /// It should be used to set parameters which are not yet available through their own
5143 /// setters.
5144 ///
5145 /// Please note that this method must not be used to set any of the known parameters
5146 /// which have their own setter method. If done anyway, the request will fail.
5147 ///
5148 /// # Additional Parameters
5149 ///
5150 /// * *$.xgafv* (query-string) - V1 error format.
5151 /// * *access_token* (query-string) - OAuth access token.
5152 /// * *alt* (query-string) - Data format for response.
5153 /// * *callback* (query-string) - JSONP
5154 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5155 /// * *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.
5156 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5157 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5158 /// * *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.
5159 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5160 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5161 pub fn param<T>(mut self, name: T, value: T) -> ProviderEntitlementSuspendCall<'a, C>
5162 where
5163 T: AsRef<str>,
5164 {
5165 self._additional_params
5166 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5167 self
5168 }
5169
5170 /// Identifies the authorization scope for the method you are building.
5171 ///
5172 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5173 /// [`Scope::CloudPlatform`].
5174 ///
5175 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5176 /// tokens for more than one scope.
5177 ///
5178 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5179 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5180 /// sufficient, a read-write scope will do as well.
5181 pub fn add_scope<St>(mut self, scope: St) -> ProviderEntitlementSuspendCall<'a, C>
5182 where
5183 St: AsRef<str>,
5184 {
5185 self._scopes.insert(String::from(scope.as_ref()));
5186 self
5187 }
5188 /// Identifies the authorization scope(s) for the method you are building.
5189 ///
5190 /// See [`Self::add_scope()`] for details.
5191 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProviderEntitlementSuspendCall<'a, C>
5192 where
5193 I: IntoIterator<Item = St>,
5194 St: AsRef<str>,
5195 {
5196 self._scopes
5197 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5198 self
5199 }
5200
5201 /// Removes all scopes, and no default scope will be used either.
5202 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5203 /// for details).
5204 pub fn clear_scopes(mut self) -> ProviderEntitlementSuspendCall<'a, C> {
5205 self._scopes.clear();
5206 self
5207 }
5208}