#![allow(clippy::ptr_arg)] use std::collections::{BTreeSet, HashMap}; use tokio::time::sleep; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] pub enum Scope { /// Associate you with your personal info on Google Openid, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::Openid => "openid", } } } #[allow(clippy::derivable_impls)] impl Default for Scope { fn default() -> Scope { Scope::Openid } } // ######## // HUB ### // ###### /// Central instance to access all PaymentsResellerSubscription related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1Subscription; /// use paymentsresellersubscription1::{Result, Error}; /// # async fn dox() { /// use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: yup_oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_create(req, "parent") /// .subscription_id("At") /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct PaymentsResellerSubscription { pub client: common::Client, pub auth: Box, _user_agent: String, _base_url: String, _root_url: String, } impl common::Hub for PaymentsResellerSubscription {} impl<'a, C> PaymentsResellerSubscription { pub fn new( client: common::Client, auth: A, ) -> PaymentsResellerSubscription { PaymentsResellerSubscription { client, auth: Box::new(auth), _user_agent: "google-api-rust-client/6.0.0".to_string(), _base_url: "https://paymentsresellersubscription.googleapis.com/".to_string(), _root_url: "https://paymentsresellersubscription.googleapis.com/".to_string(), } } pub fn partners(&'a self) -> PartnerMethods<'a, C> { PartnerMethods { hub: self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/6.0.0`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { std::mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://paymentsresellersubscription.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { std::mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://paymentsresellersubscription.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { std::mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Describes the amount unit including the currency code. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Amount { /// Required. Amount in micros (1_000_000 micros = 1 currency unit) #[serde(rename = "amountMicros")] #[serde_as(as = "Option")] pub amount_micros: Option, /// Required. Currency codes in accordance with [ISO-4217 Currency Codes] (https://en.wikipedia.org/wiki/ISO_4217). For example, USD. #[serde(rename = "currencyCode")] pub currency_code: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Amount {} /// Request to cancel a subscription. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions cancel partners](PartnerSubscriptionCancelCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest { /// Optional. If true, Google will cancel the subscription immediately, and may or may not (based on the contract) issue a prorated refund for the remainder of the billing cycle. Otherwise, Google defers the cancelation at renewal_time, and will not issue a refund. - YouTube subscriptions must use this option currently. However, the user will still have access to the subscription until the end of the billing cycle. #[serde(rename = "cancelImmediately")] pub cancel_immediately: Option, /// Specifies the reason for the cancellation. #[serde(rename = "cancellationReason")] pub cancellation_reason: Option, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest {} /// Response that contains the cancelled subscription resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions cancel partners](PartnerSubscriptionCancelCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionResponse { /// The cancelled subscription resource. pub subscription: Option, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionResponse { } /// Describes the length of a period of a time. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Duration { /// number of duration units to be included. pub count: Option, /// The unit used for the duration pub unit: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Duration {} /// LINT.IfChange Partner request for entitling the previously provisioned subscription to an end user. The end user identity is inferred from the request OAuth context. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions entitle partners](PartnerSubscriptionEntitleCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest { /// Optional. The line items to be entitled. If unspecified, all line items will be entitled. #[serde(rename="lineItemEntitlementDetails")] pub line_item_entitlement_details: Option>, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest {} /// The details of the line item to be entitled. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequestLineItemEntitlementDetails { /// Required. The index of the line item to be entitled. #[serde(rename = "lineItemIndex")] pub line_item_index: Option, /// Optional. Only applicable if the line item corresponds to a hard bundle. Product resource names that identify the bundle elements to be entitled in the line item. If unspecified, all bundle elements will be entitled. The format is 'partners/{partner_id}/products/{product_id}'. pub products: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequestLineItemEntitlementDetails {} /// Response that contains the entitled subscription resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions entitle partners](PartnerSubscriptionEntitleCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionResponse { /// The subscription that has user linked to it. pub subscription: Option, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionResponse { } /// Request message for extending a Subscription resource. A new recurrence will be made based on the subscription schedule defined by the original product. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions extend partners](PartnerSubscriptionExtendCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest { /// Required. Specifies details of the extension. Currently, the duration of the extension must be exactly one billing cycle of the original subscription. pub extension: Option, /// Required. Restricted to 36 ASCII characters. A random UUID is recommended. The idempotency key for the request. The ID generation logic is controlled by the partner. request_id should be the same as on retries of the same request. A different request_id must be used for a extension of a different cycle. #[serde(rename = "requestId")] pub request_id: Option, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest {} /// Response that contains the timestamps after the extension. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions extend partners](PartnerSubscriptionExtendCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionResponse { /// The time at which the subscription is expected to be extended, in ISO 8061 format. UTC timezone. Example, "cycleEndTime":"2019-08-31T17:28:54.564Z" #[serde(rename = "cycleEndTime")] pub cycle_end_time: Option>, /// End of the free trial period, in ISO 8061 format. UTC timezone. Example, "freeTrialEndTime":"2019-08-31T17:28:54.564Z" This time will be set the same as initial subscription creation time if no free trial period is offered to the partner. #[serde(rename = "freeTrialEndTime")] pub free_trial_end_time: Option>, /// Output only. The time at which the subscription is expected to be renewed by Google - a new charge will be incurred and the service entitlement will be renewed. A non-immediate cancellation will take place at this time too, before which, the service entitlement for the end user will remain valid. UTC timezone in ISO 8061 format. For example: "2019-08-31T17:28:54.564Z" #[serde(rename = "renewalTime")] pub renewal_time: Option>, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionResponse { } /// Describes the details of an extension request. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Extension { /// Required. Specifies the period of access the subscription should grant. pub duration: Option, /// Required. Identifier of the end-user in partner’s system. #[serde(rename = "partnerUserToken")] pub partner_user_token: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Extension {} /// Request to find eligible promotions for the current user. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [promotions find eligible partners](PartnerPromotionFindEligibleCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest { /// Optional. Specifies the filters for the promotion results. The syntax is defined in https://google.aip.dev/160 with the following caveats: 1. Only the following features are supported: - Logical operator `AND` - Comparison operator `=` (no wildcards `*`) - Traversal operator `.` - Has operator `:` (no wildcards `*`) 2. Only the following fields are supported: - `applicableProducts` - `regionCodes` - `youtubePayload.partnerEligibilityId` - `youtubePayload.postalCode` 3. Unless explicitly mentioned above, other features are not supported. Example: `applicableProducts:partners/partner1/products/product1 AND regionCodes:US AND youtubePayload.postalCode=94043 AND youtubePayload.partnerEligibilityId=eligibility-id` pub filter: Option, /// Optional. The maximum number of promotions to return. The service may return fewer than this value. If unspecified, at most 50 products will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. #[serde(rename = "pageSize")] pub page_size: Option, /// Optional. A page token, received from a previous `ListPromotions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPromotions` must match the call that provided the page token. #[serde(rename = "pageToken")] pub page_token: Option, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest { } /// Response containing the found promotions for the current user. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [promotions find eligible partners](PartnerPromotionFindEligibleCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsResponse { /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages. #[serde(rename = "nextPageToken")] pub next_page_token: Option, /// The promotions for the current user. pub promotions: Option>, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsResponse { } /// Details for a subscriptiin line item with finite billing cycles. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1FiniteBillingCycleDetails { /// Required. The number of a subscription line item billing cycles after which billing will stop automatically. #[serde(rename = "billingCycleCountLimit")] #[serde_as(as = "Option")] pub billing_cycle_count_limit: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1FiniteBillingCycleDetails {} /// Payload specific to Google One products. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1GoogleOnePayload { /// Campaign attributed to sales of this subscription. pub campaigns: Option>, /// The type of offering the subscription was sold by the partner. e.g. VAS. pub offering: Option, /// The type of sales channel through which the subscription was sold. #[serde(rename = "salesChannel")] pub sales_channel: Option, /// The identifier for the partner store where the subscription was sold. #[serde(rename = "storeId")] pub store_id: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1GoogleOnePayload {} /// Response that contains the products. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [products list partners](PartnerProductListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ListProductsResponse { /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages. #[serde(rename = "nextPageToken")] pub next_page_token: Option, /// The products for the specified partner. pub products: Option>, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1ListProductsResponse {} /// Response that contains the promotions. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [promotions list partners](PartnerPromotionListCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ListPromotionsResponse { /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages. #[serde(rename = "nextPageToken")] pub next_page_token: Option, /// The promotions for the specified partner. pub promotions: Option>, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1ListPromotionsResponse {} /// Describes a location of an end user. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Location { /// The postal code this location refers to. Ex. "94043" #[serde(rename = "postalCode")] pub postal_code: Option, /// 2-letter ISO region code for current content region. Ex. “US” Please refers to: https://en.wikipedia.org/wiki/ISO_3166-1 #[serde(rename = "regionCode")] pub region_code: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Location {} /// A Product resource that defines a subscription service that can be resold. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Product { /// Output only. Output Only. Specifies the details for a bundle product. #[serde(rename = "bundleDetails")] pub bundle_details: Option, /// Optional. Details for a subscription line item with finite billing cycles. If unset, the line item will be charged indefinitely. #[serde(rename = "finiteBillingCycleDetails")] pub finite_billing_cycle_details: Option, /// Identifier. Response only. Resource name of the product. It will have the format of "partners/{partner_id}/products/{product_id}" pub name: Option, /// Output only. Price configs for the product in the available regions. #[serde(rename = "priceConfigs")] pub price_configs: Option>, /// Output only. Output Only. Specifies the type of the product. #[serde(rename = "productType")] pub product_type: Option, /// Output only. 2-letter ISO region code where the product is available in. Ex. "US" Please refers to: https://en.wikipedia.org/wiki/ISO_3166-1 #[serde(rename = "regionCodes")] pub region_codes: Option>, /// Output only. Specifies the length of the billing cycle of the subscription. #[serde(rename = "subscriptionBillingCycleDuration")] pub subscription_billing_cycle_duration: Option, /// Output only. Localized human readable name of the product. pub titles: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Product {} /// The individual product that is included in the bundle. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ProductBundleDetailsBundleElement { /// Required. Output only. Product resource name that identifies the bundle element. The format is 'partners/{partner_id}/products/{product_id}'. pub product: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1ProductBundleDetailsBundleElement {} /// Specifies product specific payload. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ProductPayload { /// Product-specific payloads. Payload specific to Google One products. #[serde(rename = "googleOnePayload")] pub google_one_payload: Option, /// Payload specific to Youtube products. #[serde(rename = "youtubePayload")] pub youtube_payload: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1ProductPayload {} /// Configs the prices in an available region. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ProductPriceConfig { /// Output only. The price in the region. pub amount: Option, /// Output only. 2-letter ISO region code where the product is available in. Ex. "US". #[serde(rename = "regionCode")] pub region_code: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1ProductPriceConfig {} /// A Promotion resource that defines a promotion for a subscription that can be resold. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Promotion { /// Output only. The product ids this promotion can be applied to. #[serde(rename = "applicableProducts")] pub applicable_products: Option>, /// Optional. Specifies the end time (exclusive) of the period that the promotion is available in. If unset, the promotion is available indefinitely. #[serde(rename = "endTime")] pub end_time: Option>, /// Optional. Specifies the duration of the free trial of the subscription when promotion_type is PROMOTION_TYPE_FREE_TRIAL #[serde(rename = "freeTrialDuration")] pub free_trial_duration: Option, /// Optional. Specifies the introductory pricing details when the promotion_type is PROMOTION_TYPE_INTRODUCTORY_PRICING. #[serde(rename = "introductoryPricingDetails")] pub introductory_pricing_details: Option, /// Identifier. Response only. Resource name of the subscription promotion. It will have the format of "partners/{partner_id}/promotion/{promotion_id}" pub name: Option, /// Output only. Output Only. Specifies the type of the promotion. #[serde(rename = "promotionType")] pub promotion_type: Option, /// Output only. 2-letter ISO region code where the promotion is available in. Ex. "US" Please refers to: https://en.wikipedia.org/wiki/ISO_3166-1 #[serde(rename = "regionCodes")] pub region_codes: Option>, /// Optional. Specifies the start time (inclusive) of the period that the promotion is available in. #[serde(rename = "startTime")] pub start_time: Option>, /// Output only. Localized human readable name of the promotion. pub titles: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1Promotion {} /// The details of a introductory pricing promotion. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1PromotionIntroductoryPricingDetails { /// Output only. Specifies the introductory pricing periods. #[serde(rename="introductoryPricingSpecs")] pub introductory_pricing_specs: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1PromotionIntroductoryPricingDetails {} /// The duration of an introductory pricing promotion. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1PromotionIntroductoryPricingDetailsIntroductoryPricingSpec { /// Output only. The discount amount. The value is positive. #[serde(rename = "discountAmount")] pub discount_amount: Option, /// Output only. The discount percentage in micros. For example, 50,000 represents 5%. #[serde(rename = "discountRatioMicros")] #[serde_as(as = "Option")] pub discount_ratio_micros: Option, /// Output only. Output Only. The duration of an introductory offer in billing cycles. #[serde(rename = "recurrenceCount")] pub recurrence_count: Option, /// Output only. 2-letter ISO region code where the product is available in. Ex. "US". #[serde(rename = "regionCode")] pub region_code: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1PromotionIntroductoryPricingDetailsIntroductoryPricingSpec {} /// A description of what time period or moment in time the product or service is being delivered over. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1ServicePeriod { /// Optional. The end time of the service period. Time is exclusive. #[serde(rename = "endTime")] pub end_time: Option>, /// Required. The start time of the service period. Time is inclusive. #[serde(rename = "startTime")] pub start_time: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1ServicePeriod {} /// A subscription serves as a central billing entity between an external partner and Google. The underlying Google services rely on the subscription state to grant or revoke the user’s service entitlement. It’s important to note that the subscription state may not always perfectly align with the user’s service entitlement. For example, some Google services may continue providing access to the user until the current billing cycle ends, even if the subscription has been immediately canceled. However, other services may not do the same. To fully understand the specific details, please consult the relevant contract or product policy. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions create partners](PartnerSubscriptionCreateCall) (request|response) /// * [subscriptions get partners](PartnerSubscriptionGetCall) (response) /// * [subscriptions provision partners](PartnerSubscriptionProvisionCall) (request|response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1Subscription { /// Output only. Describes the details of a cancelled subscription. Only applicable to subscription of state `STATE_CANCELLED`. #[serde(rename = "cancellationDetails")] pub cancellation_details: Option, /// Output only. System generated timestamp when the subscription is created. UTC timezone. #[serde(rename = "createTime")] pub create_time: Option>, /// Output only. The time at which the subscription is expected to be extended, in ISO 8061 format. UTC timezone. For example: "2019-08-31T17:28:54.564Z" #[serde(rename = "cycleEndTime")] pub cycle_end_time: Option>, /// Output only. Indicates if the subscription is entitled to the end user. #[serde(rename = "endUserEntitled")] pub end_user_entitled: Option, /// Output only. End of the free trial period, in ISO 8061 format. For example, "2019-08-31T17:28:54.564Z". It will be set the same as createTime if no free trial promotion is specified. #[serde(rename = "freeTrialEndTime")] pub free_trial_end_time: Option>, /// Required. The line items of the subscription. #[serde(rename = "lineItems")] pub line_items: Option>, /// Identifier. Resource name of the subscription. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}". This is available for authorizeAddon, but otherwise is response only. pub name: Option, /// Required. Identifier of the end-user in partner’s system. The value is restricted to 63 ASCII characters at the maximum. #[serde(rename = "partnerUserToken")] pub partner_user_token: Option, /// Output only. Describes the processing state of the subscription. See more details at [the lifecycle of a subscription](https://developers.google.com/payments/reseller/subscription/reference/index/Receive.Notifications#payments-subscription-lifecycle). #[serde(rename = "processingState")] pub processing_state: Option, /// Optional. Deprecated: consider using `line_items` as the input. Required. Resource name that identifies the purchased products. The format will be 'partners/{partner_id}/products/{product_id}'. pub products: Option>, /// Optional. Subscription-level promotions. Only free trial is supported on this level. It determines the first renewal time of the subscription to be the end of the free trial period. Specify the promotion resource name only when used as input. #[serde(rename = "promotionSpecs")] pub promotion_specs: Option>, /// Optional. Deprecated: consider using the top-level `promotion_specs` as the input. Optional. Resource name that identifies one or more promotions that can be applied on the product. A typical promotion for a subscription is Free trial. The format will be 'partners/{partner_id}/promotions/{promotion_id}'. pub promotions: Option>, /// Optional. The timestamp when the user transaction was made with the Partner. Specify for the case of "bundle with choice", and it must be before the provision_time (when the user makes a selection). #[serde(rename = "purchaseTime")] pub purchase_time: Option>, /// Output only. The place where partners should redirect the end-user to after creation. This field might also be populated when creation failed. However, Partners should always prepare a default URL to redirect the user in case this field is empty. #[serde(rename = "redirectUri")] pub redirect_uri: Option, /// Output only. The time at which the subscription is expected to be renewed by Google - a new charge will be incurred and the service entitlement will be renewed. A non-immediate cancellation will take place at this time too, before which, the service entitlement for the end user will remain valid. UTC timezone in ISO 8061 format. For example: "2019-08-31T17:28:54.564Z" #[serde(rename = "renewalTime")] pub renewal_time: Option>, /// Required. The location that the service is provided as indicated by the partner. #[serde(rename = "serviceLocation")] pub service_location: Option, /// Output only. Describes the state of the subscription. See more details at [the lifecycle of a subscription](https://developers.google.com/payments/reseller/subscription/reference/index/Receive.Notifications#payments-subscription-lifecycle). pub state: Option, /// Output only. System generated timestamp when the subscription is most recently updated. UTC timezone. #[serde(rename = "updateTime")] pub update_time: Option>, /// Optional. Details about the previous subscription that this new subscription upgrades/downgrades from. Only populated if this subscription is an upgrade/downgrade from another subscription. #[serde(rename = "upgradeDowngradeDetails")] pub upgrade_downgrade_details: Option, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1Subscription {} impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1Subscription {} /// Describes the details of a cancelled or cancelling subscription. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionCancellationDetails { /// Output only. The reason of the cancellation. pub reason: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionCancellationDetails {} /// Individual line item definition of a subscription. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItem { /// Output only. The price of the product/service in this line item. The amount could be the wholesale price, or it can include a cost of sale based on the contract. pub amount: Option, /// Output only. The bundle details for the line item. Only populated if the line item corresponds to a hard bundle. #[serde(rename = "bundleDetails")] pub bundle_details: Option, /// Output only. Description of this line item. pub description: Option, /// Optional. Details for a subscription line item with finite billing cycles. If unset, the line item will be charged indefinitely. Used only with LINE_ITEM_RECURRENCE_TYPE_PERIODIC. #[serde(rename = "finiteBillingCycleDetails")] pub finite_billing_cycle_details: Option, /// Output only. The free trial end time will be populated after the line item is successfully processed. End time of the line item free trial period, in ISO 8061 format. For example, "2019-08-31T17:28:54.564Z". It will be set the same as createTime if no free trial promotion is specified. #[serde(rename = "lineItemFreeTrialEndTime")] pub line_item_free_trial_end_time: Option>, /// Output only. A unique index of the subscription line item. #[serde(rename = "lineItemIndex")] pub line_item_index: Option, /// Optional. The promotions applied on the line item. It can be: - an introductory pricing promotion. - a free trial promotion. This feature is not enabled. If used, the request will be rejected. When used as input in Create or Provision API, specify its resource name only. #[serde(rename = "lineItemPromotionSpecs")] pub line_item_promotion_specs: Option>, /// Output only. Details only set for a ONE_TIME recurrence line item. #[serde(rename = "oneTimeRecurrenceDetails")] pub one_time_recurrence_details: Option< GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItemOneTimeRecurrenceDetails, >, /// Required. Product resource name that identifies one the line item The format is 'partners/{partner_id}/products/{product_id}'. pub product: Option, /// Optional. Product specific payload for this line item. #[serde(rename = "productPayload")] pub product_payload: Option, /// Output only. The recurrence type of the line item. #[serde(rename = "recurrenceType")] pub recurrence_type: Option, /// Output only. The state of the line item. pub state: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItem {} /// The details for an element in the hard bundle. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItemBundleDetailsBundleElementDetails { /// Output only. Product resource name that identifies the bundle element. The format is 'partners/{partner_id}/products/{product_id}'. pub product: Option, /// Output only. The time when this product is linked to an end user. #[serde(rename = "userAccountLinkedTime")] pub user_account_linked_time: Option>, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItemBundleDetailsBundleElementDetails {} /// Details for a ONE_TIME recurrence line item. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItemOneTimeRecurrenceDetails { /// Output only. The service period of the ONE_TIME line item. #[serde(rename = "servicePeriod")] pub service_period: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionLineItemOneTimeRecurrenceDetails { } /// Describes the spec for one promotion. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionPromotionSpec { /// Output only. The duration of the free trial if the promotion is of type FREE_TRIAL. #[serde(rename = "freeTrialDuration")] pub free_trial_duration: Option, /// Output only. The details of the introductory pricing spec if the promotion is of type INTRODUCTORY_PRICING. #[serde(rename = "introductoryPricingDetails")] pub introductory_pricing_details: Option, /// Required. Promotion resource name that identifies a promotion. The format is 'partners/{partner_id}/promotions/{promotion_id}'. pub promotion: Option, /// Output only. The type of the promotion for the spec. #[serde(rename = "type")] pub type_: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionPromotionSpec {} /// Details about the previous subscription that this new subscription upgrades/downgrades from. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1SubscriptionUpgradeDowngradeDetails { /// Required. Specifies the billing cycle spec for the new upgraded/downgraded subscription. #[serde(rename = "billingCycleSpec")] pub billing_cycle_spec: Option, /// Required. The previous subscription id to be replaced. This is not the full resource name, use the subscription_id segment only. #[serde(rename = "previousSubscriptionId")] pub previous_subscription_id: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1SubscriptionUpgradeDowngradeDetails {} /// Request to revoke a cancellation request. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions undo cancel partners](PartnerSubscriptionUndoCancelCall) (request) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest { _never_set: Option, } impl common::RequestValue for GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest { } /// Response that contains the updated subscription resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [subscriptions undo cancel partners](PartnerSubscriptionUndoCancelCall) (response) #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionResponse { /// The updated subscription resource. pub subscription: Option, } impl common::ResponseResult for GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionResponse { } /// Payload specific to Youtube products. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleCloudPaymentsResellerSubscriptionV1YoutubePayload { /// Output only. The access expiration time for this line item. #[serde(rename = "accessEndTime")] pub access_end_time: Option>, /// The list of eligibility_ids which are applicable for the line item. #[serde(rename = "partnerEligibilityIds")] pub partner_eligibility_ids: Option>, /// Optional. Specifies the plan type offered to the end user by the partner. #[serde(rename = "partnerPlanType")] pub partner_plan_type: Option, } impl common::Part for GoogleCloudPaymentsResellerSubscriptionV1YoutubePayload {} /// Localized variant of a text in a particular language. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct GoogleTypeLocalizedText { /// The text's BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. #[serde(rename = "languageCode")] pub language_code: Option, /// Localized string in the language corresponding to language_code below. pub text: Option, } impl common::Part for GoogleTypeLocalizedText {} /// Details for a bundle product. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct ProductBundleDetails { /// The individual products that are included in the bundle. #[serde(rename = "bundleElements")] pub bundle_elements: Option>, /// The entitlement mode of the bundle product. #[serde(rename = "entitlementMode")] pub entitlement_mode: Option, } impl common::Part for ProductBundleDetails {} /// The bundle details for a line item corresponding to a hard bundle. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))] #[serde_with::serde_as] #[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct SubscriptionLineItemBundleDetails { /// Output only. The details for each element in the hard bundle. #[serde(rename="bundleElementDetails")] pub bundle_element_details: Option>, } impl common::Part for SubscriptionLineItemBundleDetails {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *partner* resources. /// It is not used directly, but through the [`PaymentsResellerSubscription`] hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// /// # async fn dox() { /// use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// let secret: yup_oauth2::ApplicationSecret = Default::default(); /// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// secret, /// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// /// let client = hyper_util::client::legacy::Client::builder( /// hyper_util::rt::TokioExecutor::new() /// ) /// .build( /// hyper_rustls::HttpsConnectorBuilder::new() /// .with_native_roots() /// .unwrap() /// .https_or_http() /// .enable_http1() /// .build() /// ); /// let mut hub = PaymentsResellerSubscription::new(client, auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `products_list(...)`, `promotions_find_eligible(...)`, `promotions_list(...)`, `subscriptions_cancel(...)`, `subscriptions_create(...)`, `subscriptions_entitle(...)`, `subscriptions_extend(...)`, `subscriptions_get(...)`, `subscriptions_provision(...)` and `subscriptions_undo_cancel(...)` /// // to build up your call. /// let rb = hub.partners(); /// # } /// ``` pub struct PartnerMethods<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, } impl<'a, C> common::MethodsBuilder for PartnerMethods<'a, C> {} impl<'a, C> PartnerMethods<'a, C> { /// Create a builder to help you perform the following task: /// /// To retrieve the products that can be resold by the partner. It should be autenticated with a service account. - This API doesn't apply to YouTube products currently. /// /// # Arguments /// /// * `parent` - Required. The parent, the partner that can resell. Format: partners/{partner} pub fn products_list(&self, parent: &str) -> PartnerProductListCall<'a, C> { PartnerProductListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// To find eligible promotions for the current user. The API requires user authorization via OAuth. The bare minimum oauth scope `openid` is sufficient, which will skip the consent screen. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The parent, the partner that can resell. Format: partners/{partner} pub fn promotions_find_eligible( &self, request: GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest, parent: &str, ) -> PartnerPromotionFindEligibleCall<'a, C> { PartnerPromotionFindEligibleCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves the promotions, such as free trial, that can be used by the partner. - This API doesn't apply to YouTube promotions currently. It should be autenticated with a service account. /// /// # Arguments /// /// * `parent` - Required. The parent, the partner that can resell. Format: partners/{partner} pub fn promotions_list(&self, parent: &str) -> PartnerPromotionListCall<'a, C> { PartnerPromotionListCall { hub: self.hub, _parent: parent.to_string(), _page_token: Default::default(), _page_size: Default::default(), _filter: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Used by partners to cancel a subscription service either immediately or by the end of the current billing cycle for their customers. It should be called directly by the partner using service accounts. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the subscription resource to be cancelled. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" pub fn subscriptions_cancel( &self, request: GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest, name: &str, ) -> PartnerSubscriptionCancelCall<'a, C> { PartnerSubscriptionCancelCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Used by partners to create a subscription for their customers. The created subscription is associated with the end user inferred from the end user credentials. This API must be authorized by the end user using OAuth. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The parent resource name, which is the identifier of the partner. It will have the format of "partners/{partner_id}". pub fn subscriptions_create( &self, request: GoogleCloudPaymentsResellerSubscriptionV1Subscription, parent: &str, ) -> PartnerSubscriptionCreateCall<'a, C> { PartnerSubscriptionCreateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _subscription_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Used by partners to entitle a previously provisioned subscription to the current end user. The end user identity is inferred from the authorized credential of the request. This API must be authorized by the end user using OAuth. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the subscription resource that is entitled to the current end user. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" pub fn subscriptions_entitle( &self, request: GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest, name: &str, ) -> PartnerSubscriptionEntitleCall<'a, C> { PartnerSubscriptionEntitleCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// [Opt-in only] Most partners should be on auto-extend by default. Used by partners to extend a subscription service for their customers on an ongoing basis for the subscription to remain active and renewable. It should be called directly by the partner using service accounts. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the subscription resource to be extended. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}". pub fn subscriptions_extend( &self, request: GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest, name: &str, ) -> PartnerSubscriptionExtendCall<'a, C> { PartnerSubscriptionExtendCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Used by partners to get a subscription by id. It should be called directly by the partner using service accounts. /// /// # Arguments /// /// * `name` - Required. The name of the subscription resource to retrieve. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" pub fn subscriptions_get(&self, name: &str) -> PartnerSubscriptionGetCall<'a, C> { PartnerSubscriptionGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Used by partners to provision a subscription for their customers. This creates a subscription without associating it with the end user account. EntitleSubscription must be called separately using OAuth in order for the end user account to be associated with the subscription. It should be called directly by the partner using service accounts. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Required. The parent resource name, which is the identifier of the partner. It will have the format of "partners/{partner_id}". pub fn subscriptions_provision( &self, request: GoogleCloudPaymentsResellerSubscriptionV1Subscription, parent: &str, ) -> PartnerSubscriptionProvisionCall<'a, C> { PartnerSubscriptionProvisionCall { hub: self.hub, _request: request, _parent: parent.to_string(), _subscription_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Revokes the pending cancellation of a subscription, which is currently in `STATE_CANCEL_AT_END_OF_CYCLE` state. If the subscription is already cancelled, the request will fail. - **This API doesn't apply to YouTube subscriptions.** It should be called directly by the partner using service accounts. /// /// # Arguments /// /// * `request` - No description provided. /// * `name` - Required. The name of the subscription resource whose pending cancellation needs to be undone. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" pub fn subscriptions_undo_cancel( &self, request: GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest, name: &str, ) -> PartnerSubscriptionUndoCancelCall<'a, C> { PartnerSubscriptionUndoCancelCall { hub: self.hub, _request: request, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// To retrieve the products that can be resold by the partner. It should be autenticated with a service account. - This API doesn't apply to YouTube products currently. /// /// A builder for the *products.list* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().products_list("parent") /// .page_token("sed") /// .page_size(-2) /// .filter("takimata") /// .doit().await; /// # } /// ``` pub struct PartnerProductListCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _parent: String, _page_token: Option, _page_size: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerProductListCall<'a, C> {} impl<'a, C> PartnerProductListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1ListProductsResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.products.list", http_method: hyper::Method::GET, }); for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/products"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The parent, the partner that can resell. Format: partners/{partner} /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> PartnerProductListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. A page token, received from a previous `ListProducts` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListProducts` must match the call that provided the page token. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PartnerProductListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of products to return. The service may return fewer than this value. If unspecified, at most 50 products will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> PartnerProductListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the filters for the product results. The syntax is defined in https://google.aip.dev/160 with the following caveats: 1. Only the following features are supported: - Logical operator `AND` - Comparison operator `=` (no wildcards `*`) - Traversal operator `.` - Has operator `:` (no wildcards `*`) 2. Only the following fields are supported: - `regionCodes` - `youtubePayload.partnerEligibilityId` - `youtubePayload.postalCode` 3. Unless explicitly mentioned above, other features are not supported. Example: `regionCodes:US AND youtubePayload.postalCode=94043 AND youtubePayload.partnerEligibilityId=eligibility-id` /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> PartnerProductListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerProductListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerProductListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerProductListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerProductListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerProductListCall<'a, C> { self._scopes.clear(); self } } /// To find eligible promotions for the current user. The API requires user authorization via OAuth. The bare minimum oauth scope `openid` is sufficient, which will skip the consent screen. /// /// A builder for the *promotions.findEligible* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().promotions_find_eligible(req, "parent") /// .doit().await; /// # } /// ``` pub struct PartnerPromotionFindEligibleCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest, _parent: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerPromotionFindEligibleCall<'a, C> {} impl<'a, C> PartnerPromotionFindEligibleCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.promotions.findEligible", http_method: hyper::Method::POST, }); for &field in ["alt", "parent"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("parent", self._parent); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/promotions:findEligible"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1FindEligiblePromotionsRequest, ) -> PartnerPromotionFindEligibleCall<'a, C> { self._request = new_value; self } /// Required. The parent, the partner that can resell. Format: partners/{partner} /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> PartnerPromotionFindEligibleCall<'a, C> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerPromotionFindEligibleCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerPromotionFindEligibleCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerPromotionFindEligibleCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerPromotionFindEligibleCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerPromotionFindEligibleCall<'a, C> { self._scopes.clear(); self } } /// Retrieves the promotions, such as free trial, that can be used by the partner. - This API doesn't apply to YouTube promotions currently. It should be autenticated with a service account. /// /// A builder for the *promotions.list* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().promotions_list("parent") /// .page_token("ipsum") /// .page_size(-62) /// .filter("Lorem") /// .doit().await; /// # } /// ``` pub struct PartnerPromotionListCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _parent: String, _page_token: Option, _page_size: Option, _filter: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerPromotionListCall<'a, C> {} impl<'a, C> PartnerPromotionListCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1ListPromotionsResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.promotions.list", http_method: hyper::Method::GET, }); for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(6 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._page_token.as_ref() { params.push("pageToken", value); } if let Some(value) = self._page_size.as_ref() { params.push("pageSize", value.to_string()); } if let Some(value) = self._filter.as_ref() { params.push("filter", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/promotions"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The parent, the partner that can resell. Format: partners/{partner} /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> PartnerPromotionListCall<'a, C> { self._parent = new_value.to_string(); self } /// Optional. A page token, received from a previous `ListPromotions` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPromotions` must match the call that provided the page token. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PartnerPromotionListCall<'a, C> { self._page_token = Some(new_value.to_string()); self } /// Optional. The maximum number of promotions to return. The service may return fewer than this value. If unspecified, at most 50 products will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> PartnerPromotionListCall<'a, C> { self._page_size = Some(new_value); self } /// Optional. Specifies the filters for the promotion results. The syntax is defined in https://google.aip.dev/160 with the following caveats: 1. Only the following features are supported: - Logical operator `AND` - Comparison operator `=` (no wildcards `*`) - Traversal operator `.` - Has operator `:` (no wildcards `*`) 2. Only the following fields are supported: - `applicableProducts` - `regionCodes` - `youtubePayload.partnerEligibilityId` - `youtubePayload.postalCode` 3. Unless explicitly mentioned above, other features are not supported. Example: `applicableProducts:partners/partner1/products/product1 AND regionCodes:US AND youtubePayload.postalCode=94043 AND youtubePayload.partnerEligibilityId=eligibility-id` /// /// Sets the *filter* query property to the given value. pub fn filter(mut self, new_value: &str) -> PartnerPromotionListCall<'a, C> { self._filter = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerPromotionListCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerPromotionListCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerPromotionListCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerPromotionListCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerPromotionListCall<'a, C> { self._scopes.clear(); self } } /// Used by partners to cancel a subscription service either immediately or by the end of the current billing cycle for their customers. It should be called directly by the partner using service accounts. /// /// A builder for the *subscriptions.cancel* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_cancel(req, "name") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionCancelCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionCancelCall<'a, C> {} impl<'a, C> PartnerSubscriptionCancelCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.cancel", http_method: hyper::Method::POST, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1CancelSubscriptionRequest, ) -> PartnerSubscriptionCancelCall<'a, C> { self._request = new_value; self } /// Required. The name of the subscription resource to be cancelled. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> PartnerSubscriptionCancelCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionCancelCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionCancelCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionCancelCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionCancelCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionCancelCall<'a, C> { self._scopes.clear(); self } } /// Used by partners to create a subscription for their customers. The created subscription is associated with the end user inferred from the end user credentials. This API must be authorized by the end user using OAuth. /// /// A builder for the *subscriptions.create* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1Subscription; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_create(req, "parent") /// .subscription_id("dolor") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionCreateCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1Subscription, _parent: String, _subscription_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionCreateCall<'a, C> {} impl<'a, C> PartnerSubscriptionCreateCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1Subscription, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.create", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "subscriptionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._subscription_id.as_ref() { params.push("subscriptionId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/subscriptions"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1Subscription, ) -> PartnerSubscriptionCreateCall<'a, C> { self._request = new_value; self } /// Required. The parent resource name, which is the identifier of the partner. It will have the format of "partners/{partner_id}". /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> PartnerSubscriptionCreateCall<'a, C> { self._parent = new_value.to_string(); self } /// Required. Identifies the subscription resource on the Partner side. The value is restricted to 63 ASCII characters at the maximum. If a subscription was previously created with the same subscription_id, we will directly return that one. /// /// Sets the *subscription id* query property to the given value. pub fn subscription_id(mut self, new_value: &str) -> PartnerSubscriptionCreateCall<'a, C> { self._subscription_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionCreateCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionCreateCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionCreateCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionCreateCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionCreateCall<'a, C> { self._scopes.clear(); self } } /// Used by partners to entitle a previously provisioned subscription to the current end user. The end user identity is inferred from the authorized credential of the request. This API must be authorized by the end user using OAuth. /// /// A builder for the *subscriptions.entitle* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_entitle(req, "name") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionEntitleCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionEntitleCall<'a, C> {} impl<'a, C> PartnerSubscriptionEntitleCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.entitle", http_method: hyper::Method::POST, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}:entitle"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1EntitleSubscriptionRequest, ) -> PartnerSubscriptionEntitleCall<'a, C> { self._request = new_value; self } /// Required. The name of the subscription resource that is entitled to the current end user. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> PartnerSubscriptionEntitleCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionEntitleCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionEntitleCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionEntitleCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionEntitleCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionEntitleCall<'a, C> { self._scopes.clear(); self } } /// [Opt-in only] Most partners should be on auto-extend by default. Used by partners to extend a subscription service for their customers on an ongoing basis for the subscription to remain active and renewable. It should be called directly by the partner using service accounts. /// /// A builder for the *subscriptions.extend* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_extend(req, "name") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionExtendCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionExtendCall<'a, C> {} impl<'a, C> PartnerSubscriptionExtendCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.extend", http_method: hyper::Method::POST, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}:extend"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1ExtendSubscriptionRequest, ) -> PartnerSubscriptionExtendCall<'a, C> { self._request = new_value; self } /// Required. The name of the subscription resource to be extended. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}". /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> PartnerSubscriptionExtendCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionExtendCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionExtendCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionExtendCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionExtendCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionExtendCall<'a, C> { self._scopes.clear(); self } } /// Used by partners to get a subscription by id. It should be called directly by the partner using service accounts. /// /// A builder for the *subscriptions.get* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_get("name") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionGetCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionGetCall<'a, C> {} impl<'a, C> PartnerSubscriptionGetCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1Subscription, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.get", http_method: hyper::Method::GET, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(3 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::GET) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_LENGTH, 0_u64) .body(common::to_body::(None)); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// Required. The name of the subscription resource to retrieve. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> PartnerSubscriptionGetCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionGetCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionGetCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionGetCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionGetCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionGetCall<'a, C> { self._scopes.clear(); self } } /// Used by partners to provision a subscription for their customers. This creates a subscription without associating it with the end user account. EntitleSubscription must be called separately using OAuth in order for the end user account to be associated with the subscription. It should be called directly by the partner using service accounts. /// /// A builder for the *subscriptions.provision* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1Subscription; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1Subscription::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_provision(req, "parent") /// .subscription_id("duo") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionProvisionCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1Subscription, _parent: String, _subscription_id: Option, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionProvisionCall<'a, C> {} impl<'a, C> PartnerSubscriptionProvisionCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1Subscription, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.provision", http_method: hyper::Method::POST, }); for &field in ["alt", "parent", "subscriptionId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(5 + self._additional_params.len()); params.push("parent", self._parent); if let Some(value) = self._subscription_id.as_ref() { params.push("subscriptionId", value); } params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+parent}/subscriptions:provision"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+parent}", "parent")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["parent"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1Subscription, ) -> PartnerSubscriptionProvisionCall<'a, C> { self._request = new_value; self } /// Required. The parent resource name, which is the identifier of the partner. It will have the format of "partners/{partner_id}". /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> PartnerSubscriptionProvisionCall<'a, C> { self._parent = new_value.to_string(); self } /// Required. Identifies the subscription resource on the Partner side. The value is restricted to 63 ASCII characters at the maximum. If a subscription was previously created with the same subscription_id, we will directly return that one. /// /// Sets the *subscription id* query property to the given value. pub fn subscription_id(mut self, new_value: &str) -> PartnerSubscriptionProvisionCall<'a, C> { self._subscription_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionProvisionCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionProvisionCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionProvisionCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionProvisionCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionProvisionCall<'a, C> { self._scopes.clear(); self } } /// Revokes the pending cancellation of a subscription, which is currently in `STATE_CANCEL_AT_END_OF_CYCLE` state. If the subscription is already cancelled, the request will fail. - **This API doesn't apply to YouTube subscriptions.** It should be called directly by the partner using service accounts. /// /// A builder for the *subscriptions.undoCancel* method supported by a *partner* resource. /// It is not used directly, but through a [`PartnerMethods`] instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_paymentsresellersubscription1 as paymentsresellersubscription1; /// use paymentsresellersubscription1::api::GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest; /// # async fn dox() { /// # use paymentsresellersubscription1::{PaymentsResellerSubscription, FieldMask, hyper_rustls, hyper_util, yup_oauth2}; /// /// # let secret: yup_oauth2::ApplicationSecret = Default::default(); /// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// /// # let client = hyper_util::client::legacy::Client::builder( /// # hyper_util::rt::TokioExecutor::new() /// # ) /// # .build( /// # hyper_rustls::HttpsConnectorBuilder::new() /// # .with_native_roots() /// # .unwrap() /// # .https_or_http() /// # .enable_http1() /// # .build() /// # ); /// # let mut hub = PaymentsResellerSubscription::new(client, auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.partners().subscriptions_undo_cancel(req, "name") /// .doit().await; /// # } /// ``` pub struct PartnerSubscriptionUndoCancelCall<'a, C> where C: 'a, { hub: &'a PaymentsResellerSubscription, _request: GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest, _name: String, _delegate: Option<&'a mut dyn common::Delegate>, _additional_params: HashMap, _scopes: BTreeSet, } impl<'a, C> common::CallBuilder for PartnerSubscriptionUndoCancelCall<'a, C> {} impl<'a, C> PartnerSubscriptionUndoCancelCall<'a, C> where C: common::Connector, { /// Perform the operation you have build so far. pub async fn doit( mut self, ) -> common::Result<( common::Response, GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionResponse, )> { use std::borrow::Cow; use std::io::{Read, Seek}; use common::{url::Params, ToParts}; use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT}; let mut dd = common::DefaultDelegate; let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd); dlg.begin(common::MethodInfo { id: "paymentsresellersubscription.partners.subscriptions.undoCancel", http_method: hyper::Method::POST, }); for &field in ["alt", "name"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(common::Error::FieldClash(field)); } } let mut params = Params::with_capacity(4 + self._additional_params.len()); params.push("name", self._name); params.extend(self._additional_params.iter()); params.push("alt", "json"); let mut url = self.hub._base_url.clone() + "v1/{+name}:undoCancel"; if self._scopes.is_empty() { self._scopes.insert(Scope::Openid.as_ref().to_string()); } #[allow(clippy::single_element_loop)] for &(find_this, param_name) in [("{+name}", "name")].iter() { url = params.uri_replacement(url, param_name, find_this, true); } { let to_remove = ["name"]; params.remove_params(&to_remove); } let url = params.parse_with_url(&url); let mut json_mime_type = mime::APPLICATION_JSON; let mut request_value_reader = { let mut value = serde_json::value::to_value(&self._request).expect("serde to work"); common::remove_json_null_values(&mut value); let mut dst = std::io::Cursor::new(Vec::with_capacity(128)); serde_json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader .seek(std::io::SeekFrom::End(0)) .unwrap(); request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); loop { let token = match self .hub .auth .get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]) .await { Ok(token) => token, Err(e) => match dlg.token(e) { Ok(token) => token, Err(e) => { dlg.finished(false); return Err(common::Error::MissingToken(e)); } }, }; request_value_reader .seek(std::io::SeekFrom::Start(0)) .unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder() .method(hyper::Method::POST) .uri(url.as_str()) .header(USER_AGENT, self.hub._user_agent.clone()); if let Some(token) = token.as_ref() { req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); } let request = req_builder .header(CONTENT_TYPE, json_mime_type.to_string()) .header(CONTENT_LENGTH, request_size as u64) .body(common::to_body( request_value_reader.get_ref().clone().into(), )); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let common::Retry::After(d) = dlg.http_error(&err) { sleep(d).await; continue; } dlg.finished(false); return Err(common::Error::HttpError(err)); } Ok(res) => { let (mut parts, body) = res.into_parts(); let mut body = common::Body::new(body); if !parts.status.is_success() { let bytes = common::to_bytes(body).await.unwrap_or_default(); let error = serde_json::from_str(&common::to_string(&bytes)); let response = common::to_response(parts, bytes.into()); if let common::Retry::After(d) = dlg.http_failure(&response, error.as_ref().ok()) { sleep(d).await; continue; } dlg.finished(false); return Err(match error { Ok(value) => common::Error::BadRequest(value), _ => common::Error::Failure(response), }); } let response = { let bytes = common::to_bytes(body).await.unwrap_or_default(); let encoded = common::to_string(&bytes); match serde_json::from_str(&encoded) { Ok(decoded) => (common::to_response(parts, bytes.into()), decoded), Err(error) => { dlg.response_json_decode_error(&encoded, &error); return Err(common::Error::JsonDecodeError( encoded.to_string(), error, )); } } }; dlg.finished(true); return Ok(response); } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request( mut self, new_value: GoogleCloudPaymentsResellerSubscriptionV1UndoCancelSubscriptionRequest, ) -> PartnerSubscriptionUndoCancelCall<'a, C> { self._request = new_value; self } /// Required. The name of the subscription resource whose pending cancellation needs to be undone. It will have the format of "partners/{partner_id}/subscriptions/{subscription_id}" /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> PartnerSubscriptionUndoCancelCall<'a, C> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// ````text /// It should be used to handle progress information, and to implement a certain level of resilience. /// ```` /// /// Sets the *delegate* property to the given value. pub fn delegate( mut self, new_value: &'a mut dyn common::Delegate, ) -> PartnerSubscriptionUndoCancelCall<'a, C> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *$.xgafv* (query-string) - V1 error format. /// * *access_token* (query-string) - OAuth access token. /// * *alt* (query-string) - Data format for response. /// * *callback* (query-string) - JSONP /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). pub fn param(mut self, name: T, value: T) -> PartnerSubscriptionUndoCancelCall<'a, C> where T: AsRef, { self._additional_params .insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant /// [`Scope::Openid`]. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: St) -> PartnerSubscriptionUndoCancelCall<'a, C> where St: AsRef, { self._scopes.insert(String::from(scope.as_ref())); self } /// Identifies the authorization scope(s) for the method you are building. /// /// See [`Self::add_scope()`] for details. pub fn add_scopes(mut self, scopes: I) -> PartnerSubscriptionUndoCancelCall<'a, C> where I: IntoIterator, St: AsRef, { self._scopes .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); self } /// Removes all scopes, and no default scope will be used either. /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] /// for details). pub fn clear_scopes(mut self) -> PartnerSubscriptionUndoCancelCall<'a, C> { self._scopes.clear(); self } }