mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-02 17:42:16 +01:00
15744 lines
742 KiB
Rust
15744 lines
742 KiB
Rust
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::default::Default;
|
|
use std::collections::BTreeSet;
|
|
use std::error::Error as StdError;
|
|
use serde_json as json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::mem;
|
|
|
|
use hyper::client::connect;
|
|
use tokio::io::{AsyncRead, AsyncWrite};
|
|
use tokio::time::sleep;
|
|
use tower_service;
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use crate::{client, client::GetToken, client::serde_with};
|
|
|
|
// ##############
|
|
// 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, Hash)]
|
|
pub enum Scope {
|
|
/// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
|
|
CloudPlatform,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::CloudPlatform
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all Recommender related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
|
|
/// use recommender1_beta1::{Result, Error};
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: 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 = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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.billing_accounts().locations_recommenders_recommendations_mark_claimed(req, "name")
|
|
/// .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 Recommender<S> {
|
|
pub client: hyper::Client<S, hyper::body::Body>,
|
|
pub auth: Box<dyn client::GetToken>,
|
|
_user_agent: String,
|
|
_base_url: String,
|
|
_root_url: String,
|
|
}
|
|
|
|
impl<'a, S> client::Hub for Recommender<S> {}
|
|
|
|
impl<'a, S> Recommender<S> {
|
|
|
|
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> Recommender<S> {
|
|
Recommender {
|
|
client,
|
|
auth: Box::new(auth),
|
|
_user_agent: "google-api-rust-client/5.0.2".to_string(),
|
|
_base_url: "https://recommender.googleapis.com/".to_string(),
|
|
_root_url: "https://recommender.googleapis.com/".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn billing_accounts(&'a self) -> BillingAccountMethods<'a, S> {
|
|
BillingAccountMethods { hub: &self }
|
|
}
|
|
pub fn folders(&'a self) -> FolderMethods<'a, S> {
|
|
FolderMethods { hub: &self }
|
|
}
|
|
pub fn organizations(&'a self) -> OrganizationMethods<'a, S> {
|
|
OrganizationMethods { hub: &self }
|
|
}
|
|
pub fn projects(&'a self) -> ProjectMethods<'a, S> {
|
|
ProjectMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/5.0.2`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
mem::replace(&mut self._user_agent, agent_name)
|
|
}
|
|
|
|
/// Set the base url to use in all requests to the server.
|
|
/// It defaults to `https://recommender.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set base url.
|
|
pub fn base_url(&mut self, new_base_url: String) -> String {
|
|
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://recommender.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set root url.
|
|
pub fn root_url(&mut self, new_root_url: String) -> String {
|
|
mem::replace(&mut self._root_url, new_root_url)
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// Contains metadata about how much money a recommendation can save or incur.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1CostProjection {
|
|
/// An approximate projection on amount saved or amount incurred. Negative cost units indicate cost savings and positive cost units indicate increase. See google.type.Money documentation for positive/negative units. A user's permissions may affect whether the cost is computed using list prices or custom contract prices.
|
|
|
|
pub cost: Option<GoogleTypeMoney>,
|
|
/// Duration for which this cost applies.
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub duration: Option<client::chrono::Duration>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1CostProjection {}
|
|
|
|
|
|
/// Contains the impact a recommendation can have for a given category.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1Impact {
|
|
/// Category that is being targeted.
|
|
|
|
pub category: Option<String>,
|
|
/// Use with CategoryType.COST
|
|
#[serde(rename="costProjection")]
|
|
|
|
pub cost_projection: Option<GoogleCloudRecommenderV1beta1CostProjection>,
|
|
/// Use with CategoryType.RELIABILITY
|
|
#[serde(rename="reliabilityProjection")]
|
|
|
|
pub reliability_projection: Option<GoogleCloudRecommenderV1beta1ReliabilityProjection>,
|
|
/// Use with CategoryType.SECURITY
|
|
#[serde(rename="securityProjection")]
|
|
|
|
pub security_projection: Option<GoogleCloudRecommenderV1beta1SecurityProjection>,
|
|
/// Use with CategoryType.SUSTAINABILITY
|
|
#[serde(rename="sustainabilityProjection")]
|
|
|
|
pub sustainability_projection: Option<GoogleCloudRecommenderV1beta1SustainabilityProjection>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1Impact {}
|
|
|
|
|
|
/// An insight along with the information used to derive the insight. The insight may have associated recommendations as well.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations insight types insights get billing accounts](BillingAccountLocationInsightTypeInsightGetCall) (response)
|
|
/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (response)
|
|
/// * [locations insight types insights get folders](FolderLocationInsightTypeInsightGetCall) (response)
|
|
/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (response)
|
|
/// * [locations insight types insights get organizations](OrganizationLocationInsightTypeInsightGetCall) (response)
|
|
/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (response)
|
|
/// * [locations insight types insights get projects](ProjectLocationInsightTypeInsightGetCall) (response)
|
|
/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1Insight {
|
|
/// Recommendations derived from this insight.
|
|
#[serde(rename="associatedRecommendations")]
|
|
|
|
pub associated_recommendations: Option<Vec<GoogleCloudRecommenderV1beta1InsightRecommendationReference>>,
|
|
/// Category being targeted by the insight.
|
|
|
|
pub category: Option<String>,
|
|
/// A struct of custom fields to explain the insight. Example: "grantedPermissionsCount": "1000"
|
|
|
|
pub content: Option<HashMap<String, json::Value>>,
|
|
/// Free-form human readable summary in English. The maximum length is 500 characters.
|
|
|
|
pub description: Option<String>,
|
|
/// Fingerprint of the Insight. Provides optimistic locking when updating states.
|
|
|
|
pub etag: Option<String>,
|
|
/// Insight subtype. Insight content schema will be stable for a given subtype.
|
|
#[serde(rename="insightSubtype")]
|
|
|
|
pub insight_subtype: Option<String>,
|
|
/// Timestamp of the latest data used to generate the insight.
|
|
#[serde(rename="lastRefreshTime")]
|
|
|
|
pub last_refresh_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
|
/// Name of the insight.
|
|
|
|
pub name: Option<String>,
|
|
/// Observation period that led to the insight. The source data used to generate the insight ends at last_refresh_time and begins at (last_refresh_time - observation_period).
|
|
#[serde(rename="observationPeriod")]
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub observation_period: Option<client::chrono::Duration>,
|
|
/// Insight's severity.
|
|
|
|
pub severity: Option<String>,
|
|
/// Information state and metadata.
|
|
#[serde(rename="stateInfo")]
|
|
|
|
pub state_info: Option<GoogleCloudRecommenderV1beta1InsightStateInfo>,
|
|
/// Fully qualified resource names that this insight is targeting.
|
|
#[serde(rename="targetResources")]
|
|
|
|
pub target_resources: Option<Vec<String>>,
|
|
}
|
|
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1Insight {}
|
|
|
|
|
|
/// Reference to an associated recommendation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1InsightRecommendationReference {
|
|
/// Recommendation resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
|
|
|
|
pub recommendation: Option<String>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1InsightRecommendationReference {}
|
|
|
|
|
|
/// Information related to insight state.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1InsightStateInfo {
|
|
/// Insight state.
|
|
|
|
pub state: Option<String>,
|
|
/// A map of metadata for the state, provided by user or automations systems.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1InsightStateInfo {}
|
|
|
|
|
|
/// Configuration for an InsightType.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations insight types get config billing accounts](BillingAccountLocationInsightTypeGetConfigCall) (response)
|
|
/// * [locations insight types update config billing accounts](BillingAccountLocationInsightTypeUpdateConfigCall) (request|response)
|
|
/// * [locations insight types get config organizations](OrganizationLocationInsightTypeGetConfigCall) (response)
|
|
/// * [locations insight types update config organizations](OrganizationLocationInsightTypeUpdateConfigCall) (request|response)
|
|
/// * [locations insight types get config projects](ProjectLocationInsightTypeGetConfigCall) (response)
|
|
/// * [locations insight types update config projects](ProjectLocationInsightTypeUpdateConfigCall) (request|response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1InsightTypeConfig {
|
|
/// Allows clients to store small amounts of arbitrary data. Annotations must follow the Kubernetes syntax. The total size of all keys and values combined is limited to 256k. Key can have 2 segments: prefix (optional) and name (required), separated by a slash (/). Prefix must be a DNS subdomain. Name must be 63 characters or less, begin and end with alphanumerics, with dashes (-), underscores (_), dots (.), and alphanumerics between.
|
|
|
|
pub annotations: Option<HashMap<String, String>>,
|
|
/// A user-settable field to provide a human-readable name to be used in user interfaces.
|
|
#[serde(rename="displayName")]
|
|
|
|
pub display_name: Option<String>,
|
|
/// Fingerprint of the InsightTypeConfig. Provides optimistic locking when updating.
|
|
|
|
pub etag: Option<String>,
|
|
/// InsightTypeGenerationConfig which configures the generation of insights for this insight type.
|
|
#[serde(rename="insightTypeGenerationConfig")]
|
|
|
|
pub insight_type_generation_config: Option<GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig>,
|
|
/// Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
|
|
pub name: Option<String>,
|
|
/// Output only. Immutable. The revision ID of the config. A new revision is committed whenever the config is changed in any way. The format is an 8-character hexadecimal string.
|
|
#[serde(rename="revisionId")]
|
|
|
|
pub revision_id: Option<String>,
|
|
/// Last time when the config was updated.
|
|
#[serde(rename="updateTime")]
|
|
|
|
pub update_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1InsightTypeConfig {}
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1InsightTypeConfig {}
|
|
|
|
|
|
/// A configuration to customize the generation of insights. Eg, customizing the lookback period considered when generating a insight.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig {
|
|
/// Parameters for this InsightTypeGenerationConfig. These configs can be used by or are applied to all subtypes.
|
|
|
|
pub params: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1InsightTypeGenerationConfig {}
|
|
|
|
|
|
/// Response to the `ListInsights` method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations insight types insights list billing accounts](BillingAccountLocationInsightTypeInsightListCall) (response)
|
|
/// * [locations insight types insights list folders](FolderLocationInsightTypeInsightListCall) (response)
|
|
/// * [locations insight types insights list organizations](OrganizationLocationInsightTypeInsightListCall) (response)
|
|
/// * [locations insight types insights list projects](ProjectLocationInsightTypeInsightListCall) (response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1ListInsightsResponse {
|
|
/// The set of insights for the `parent` resource.
|
|
|
|
pub insights: Option<Vec<GoogleCloudRecommenderV1beta1Insight>>,
|
|
/// A token that can be used to request the next page of results. This field is empty if there are no additional results.
|
|
#[serde(rename="nextPageToken")]
|
|
|
|
pub next_page_token: Option<String>,
|
|
}
|
|
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1ListInsightsResponse {}
|
|
|
|
|
|
/// Response to the `ListRecommendations` method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations list billing accounts](BillingAccountLocationRecommenderRecommendationListCall) (response)
|
|
/// * [locations recommenders recommendations list folders](FolderLocationRecommenderRecommendationListCall) (response)
|
|
/// * [locations recommenders recommendations list organizations](OrganizationLocationRecommenderRecommendationListCall) (response)
|
|
/// * [locations recommenders recommendations list projects](ProjectLocationRecommenderRecommendationListCall) (response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1ListRecommendationsResponse {
|
|
/// A token that can be used to request the next page of results. This field is empty if there are no additional results.
|
|
#[serde(rename="nextPageToken")]
|
|
|
|
pub next_page_token: Option<String>,
|
|
/// The set of recommendations for the `parent` resource.
|
|
|
|
pub recommendations: Option<Vec<GoogleCloudRecommenderV1beta1Recommendation>>,
|
|
}
|
|
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1ListRecommendationsResponse {}
|
|
|
|
|
|
/// Request for the `MarkInsightAccepted` method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations insight types insights mark accepted billing accounts](BillingAccountLocationInsightTypeInsightMarkAcceptedCall) (request)
|
|
/// * [locations insight types insights mark accepted folders](FolderLocationInsightTypeInsightMarkAcceptedCall) (request)
|
|
/// * [locations insight types insights mark accepted organizations](OrganizationLocationInsightTypeInsightMarkAcceptedCall) (request)
|
|
/// * [locations insight types insights mark accepted projects](ProjectLocationInsightTypeInsightMarkAcceptedCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest {
|
|
/// Required. Fingerprint of the Insight. Provides optimistic locking.
|
|
|
|
pub etag: Option<String>,
|
|
/// Optional. State properties user wish to include with this state. Full replace of the current state_metadata.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest {}
|
|
|
|
|
|
/// Request for the `MarkRecommendationClaimed` Method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (request)
|
|
/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (request)
|
|
/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (request)
|
|
/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest {
|
|
/// Required. Fingerprint of the Recommendation. Provides optimistic locking.
|
|
|
|
pub etag: Option<String>,
|
|
/// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest {}
|
|
|
|
|
|
/// Request for the `MarkRecommendationDismissed` Method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (request)
|
|
/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (request)
|
|
/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (request)
|
|
/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest {
|
|
/// Fingerprint of the Recommendation. Provides optimistic locking.
|
|
|
|
pub etag: Option<String>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest {}
|
|
|
|
|
|
/// Request for the `MarkRecommendationFailed` Method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (request)
|
|
/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (request)
|
|
/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (request)
|
|
/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest {
|
|
/// Required. Fingerprint of the Recommendation. Provides optimistic locking.
|
|
|
|
pub etag: Option<String>,
|
|
/// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest {}
|
|
|
|
|
|
/// Request for the `MarkRecommendationSucceeded` Method.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (request)
|
|
/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (request)
|
|
/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (request)
|
|
/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (request)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest {
|
|
/// Required. Fingerprint of the Recommendation. Provides optimistic locking.
|
|
|
|
pub etag: Option<String>,
|
|
/// State properties to include with this state. Overwrites any existing `state_metadata`. Keys must match the regex `/^a-z0-9{0,62}$/`. Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest {}
|
|
|
|
|
|
/// Contains an operation for a resource loosely based on the JSON-PATCH format with support for: * Custom filters for describing partial array patch. * Extended path values for describing nested arrays. * Custom fields for describing the resource for which the operation is being described. * Allows extension to custom operations not natively supported by RFC6902. See https://tools.ietf.org/html/rfc6902 for details on the original RFC.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1Operation {
|
|
/// Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', 'copy', 'test' and 'custom' operations. This field is case-insensitive and always populated.
|
|
|
|
pub action: Option<String>,
|
|
/// Path to the target field being operated on. If the operation is at the resource level, then path should be "/". This field is always populated.
|
|
|
|
pub path: Option<String>,
|
|
/// Set of filters to apply if `path` refers to array elements or nested array elements in order to narrow down to a single unique element that is being tested/modified. This is intended to be an exact match per filter. To perform advanced matching, use path_value_matchers. * Example: ``` { "/versions/*/name" : "it-123" "/versions/*/targetSize/percent": 20 } ``` * Example: ``` { "/bindings/*/role": "roles/owner" "/bindings/*/condition" : null } ``` * Example: ``` { "/bindings/*/role": "roles/owner" "/bindings/*/members/*" : ["x@example.com", "y@example.com"] } ``` When both path_filters and path_value_matchers are set, an implicit AND must be performed.
|
|
#[serde(rename="pathFilters")]
|
|
|
|
pub path_filters: Option<HashMap<String, json::Value>>,
|
|
/// Similar to path_filters, this contains set of filters to apply if `path` field refers to array elements. This is meant to support value matching beyond exact match. To perform exact match, use path_filters. When both path_filters and path_value_matchers are set, an implicit AND must be performed.
|
|
#[serde(rename="pathValueMatchers")]
|
|
|
|
pub path_value_matchers: Option<HashMap<String, GoogleCloudRecommenderV1beta1ValueMatcher>>,
|
|
/// Contains the fully qualified resource name. This field is always populated. ex: //cloudresourcemanager.googleapis.com/projects/foo.
|
|
|
|
pub resource: Option<String>,
|
|
/// Type of GCP resource being modified/tested. This field is always populated. Example: cloudresourcemanager.googleapis.com/Project, compute.googleapis.com/Instance
|
|
#[serde(rename="resourceType")]
|
|
|
|
pub resource_type: Option<String>,
|
|
/// Can be set with action 'copy' or 'move' to indicate the source field within resource or source_resource, ignored if provided for other operation types.
|
|
#[serde(rename="sourcePath")]
|
|
|
|
pub source_path: Option<String>,
|
|
/// Can be set with action 'copy' to copy resource configuration across different resources of the same type. Example: A resource clone can be done via action = 'copy', path = "/", from = "/", source_resource = and resource_name = . This field is empty for all other values of `action`.
|
|
#[serde(rename="sourceResource")]
|
|
|
|
pub source_resource: Option<String>,
|
|
/// Value for the `path` field. Will be set for actions:'add'/'replace'. Maybe set for action: 'test'. Either this or `value_matcher` will be set for 'test' operation. An exact match must be performed.
|
|
|
|
pub value: Option<json::Value>,
|
|
/// Can be set for action 'test' for advanced matching for the value of 'path' field. Either this or `value` will be set for 'test' operation.
|
|
#[serde(rename="valueMatcher")]
|
|
|
|
pub value_matcher: Option<GoogleCloudRecommenderV1beta1ValueMatcher>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1Operation {}
|
|
|
|
|
|
/// Group of operations that need to be performed atomically.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1OperationGroup {
|
|
/// List of operations across one or more resources that belong to this group. Loosely based on RFC6902 and should be performed in the order they appear.
|
|
|
|
pub operations: Option<Vec<GoogleCloudRecommenderV1beta1Operation>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1OperationGroup {}
|
|
|
|
|
|
/// A recommendation along with a suggested action. E.g., a rightsizing recommendation for an underutilized VM, IAM role recommendations, etc
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders recommendations get billing accounts](BillingAccountLocationRecommenderRecommendationGetCall) (response)
|
|
/// * [locations recommenders recommendations mark claimed billing accounts](BillingAccountLocationRecommenderRecommendationMarkClaimedCall) (response)
|
|
/// * [locations recommenders recommendations mark dismissed billing accounts](BillingAccountLocationRecommenderRecommendationMarkDismissedCall) (response)
|
|
/// * [locations recommenders recommendations mark failed billing accounts](BillingAccountLocationRecommenderRecommendationMarkFailedCall) (response)
|
|
/// * [locations recommenders recommendations mark succeeded billing accounts](BillingAccountLocationRecommenderRecommendationMarkSucceededCall) (response)
|
|
/// * [locations recommenders recommendations get folders](FolderLocationRecommenderRecommendationGetCall) (response)
|
|
/// * [locations recommenders recommendations mark claimed folders](FolderLocationRecommenderRecommendationMarkClaimedCall) (response)
|
|
/// * [locations recommenders recommendations mark dismissed folders](FolderLocationRecommenderRecommendationMarkDismissedCall) (response)
|
|
/// * [locations recommenders recommendations mark failed folders](FolderLocationRecommenderRecommendationMarkFailedCall) (response)
|
|
/// * [locations recommenders recommendations mark succeeded folders](FolderLocationRecommenderRecommendationMarkSucceededCall) (response)
|
|
/// * [locations recommenders recommendations get organizations](OrganizationLocationRecommenderRecommendationGetCall) (response)
|
|
/// * [locations recommenders recommendations mark claimed organizations](OrganizationLocationRecommenderRecommendationMarkClaimedCall) (response)
|
|
/// * [locations recommenders recommendations mark dismissed organizations](OrganizationLocationRecommenderRecommendationMarkDismissedCall) (response)
|
|
/// * [locations recommenders recommendations mark failed organizations](OrganizationLocationRecommenderRecommendationMarkFailedCall) (response)
|
|
/// * [locations recommenders recommendations mark succeeded organizations](OrganizationLocationRecommenderRecommendationMarkSucceededCall) (response)
|
|
/// * [locations recommenders recommendations get projects](ProjectLocationRecommenderRecommendationGetCall) (response)
|
|
/// * [locations recommenders recommendations mark claimed projects](ProjectLocationRecommenderRecommendationMarkClaimedCall) (response)
|
|
/// * [locations recommenders recommendations mark dismissed projects](ProjectLocationRecommenderRecommendationMarkDismissedCall) (response)
|
|
/// * [locations recommenders recommendations mark failed projects](ProjectLocationRecommenderRecommendationMarkFailedCall) (response)
|
|
/// * [locations recommenders recommendations mark succeeded projects](ProjectLocationRecommenderRecommendationMarkSucceededCall) (response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1Recommendation {
|
|
/// Optional set of additional impact that this recommendation may have when trying to optimize for the primary category. These may be positive or negative.
|
|
#[serde(rename="additionalImpact")]
|
|
|
|
pub additional_impact: Option<Vec<GoogleCloudRecommenderV1beta1Impact>>,
|
|
/// Insights that led to this recommendation.
|
|
#[serde(rename="associatedInsights")]
|
|
|
|
pub associated_insights: Option<Vec<GoogleCloudRecommenderV1beta1RecommendationInsightReference>>,
|
|
/// Content of the recommendation describing recommended changes to resources.
|
|
|
|
pub content: Option<GoogleCloudRecommenderV1beta1RecommendationContent>,
|
|
/// Free-form human readable summary in English. The maximum length is 500 characters.
|
|
|
|
pub description: Option<String>,
|
|
/// Fingerprint of the Recommendation. Provides optimistic locking when updating states.
|
|
|
|
pub etag: Option<String>,
|
|
/// Last time this recommendation was refreshed by the system that created it in the first place.
|
|
#[serde(rename="lastRefreshTime")]
|
|
|
|
pub last_refresh_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
|
/// Name of recommendation.
|
|
|
|
pub name: Option<String>,
|
|
/// The primary impact that this recommendation can have while trying to optimize for one category.
|
|
#[serde(rename="primaryImpact")]
|
|
|
|
pub primary_impact: Option<GoogleCloudRecommenderV1beta1Impact>,
|
|
/// Recommendation's priority.
|
|
|
|
pub priority: Option<String>,
|
|
/// Contains an identifier for a subtype of recommendations produced for the same recommender. Subtype is a function of content and impact, meaning a new subtype might be added when significant changes to `content` or `primary_impact.category` are introduced. See the Recommenders section to see a list of subtypes for a given Recommender. Examples: For recommender = "google.iam.policy.Recommender", recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE"
|
|
#[serde(rename="recommenderSubtype")]
|
|
|
|
pub recommender_subtype: Option<String>,
|
|
/// Information for state. Contains state and metadata.
|
|
#[serde(rename="stateInfo")]
|
|
|
|
pub state_info: Option<GoogleCloudRecommenderV1beta1RecommendationStateInfo>,
|
|
/// Corresponds to a mutually exclusive group ID within a recommender. A non-empty ID indicates that the recommendation belongs to a mutually exclusive group. This means that only one recommendation within the group is suggested to be applied.
|
|
#[serde(rename="xorGroupId")]
|
|
|
|
pub xor_group_id: Option<String>,
|
|
}
|
|
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1Recommendation {}
|
|
|
|
|
|
/// Contains what resources are changing and how they are changing.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1RecommendationContent {
|
|
/// Operations to one or more Google Cloud resources grouped in such a way that, all operations within one group are expected to be performed atomically and in an order.
|
|
#[serde(rename="operationGroups")]
|
|
|
|
pub operation_groups: Option<Vec<GoogleCloudRecommenderV1beta1OperationGroup>>,
|
|
/// Condensed overview information about the recommendation.
|
|
|
|
pub overview: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1RecommendationContent {}
|
|
|
|
|
|
/// Reference to an associated insight.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1RecommendationInsightReference {
|
|
/// Insight resource name, e.g. projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID]
|
|
|
|
pub insight: Option<String>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1RecommendationInsightReference {}
|
|
|
|
|
|
/// Information for state. Contains state and metadata.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1RecommendationStateInfo {
|
|
/// The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED.
|
|
|
|
pub state: Option<String>,
|
|
/// A map of metadata for the state, provided by user or automations systems.
|
|
#[serde(rename="stateMetadata")]
|
|
|
|
pub state_metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1RecommendationStateInfo {}
|
|
|
|
|
|
/// Configuration for a Recommender.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations recommenders get config billing accounts](BillingAccountLocationRecommenderGetConfigCall) (response)
|
|
/// * [locations recommenders update config billing accounts](BillingAccountLocationRecommenderUpdateConfigCall) (request|response)
|
|
/// * [locations recommenders get config organizations](OrganizationLocationRecommenderGetConfigCall) (response)
|
|
/// * [locations recommenders update config organizations](OrganizationLocationRecommenderUpdateConfigCall) (request|response)
|
|
/// * [locations recommenders get config projects](ProjectLocationRecommenderGetConfigCall) (response)
|
|
/// * [locations recommenders update config projects](ProjectLocationRecommenderUpdateConfigCall) (request|response)
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1RecommenderConfig {
|
|
/// Allows clients to store small amounts of arbitrary data. Annotations must follow the Kubernetes syntax. The total size of all keys and values combined is limited to 256k. Key can have 2 segments: prefix (optional) and name (required), separated by a slash (/). Prefix must be a DNS subdomain. Name must be 63 characters or less, begin and end with alphanumerics, with dashes (-), underscores (_), dots (.), and alphanumerics between.
|
|
|
|
pub annotations: Option<HashMap<String, String>>,
|
|
/// A user-settable field to provide a human-readable name to be used in user interfaces.
|
|
#[serde(rename="displayName")]
|
|
|
|
pub display_name: Option<String>,
|
|
/// Fingerprint of the RecommenderConfig. Provides optimistic locking when updating.
|
|
|
|
pub etag: Option<String>,
|
|
/// Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
|
|
pub name: Option<String>,
|
|
/// RecommenderGenerationConfig which configures the Generation of recommendations for this recommender.
|
|
#[serde(rename="recommenderGenerationConfig")]
|
|
|
|
pub recommender_generation_config: Option<GoogleCloudRecommenderV1beta1RecommenderGenerationConfig>,
|
|
/// Output only. Immutable. The revision ID of the config. A new revision is committed whenever the config is changed in any way. The format is an 8-character hexadecimal string.
|
|
#[serde(rename="revisionId")]
|
|
|
|
pub revision_id: Option<String>,
|
|
/// Last time when the config was updated.
|
|
#[serde(rename="updateTime")]
|
|
|
|
pub update_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
|
}
|
|
|
|
impl client::RequestValue for GoogleCloudRecommenderV1beta1RecommenderConfig {}
|
|
impl client::ResponseResult for GoogleCloudRecommenderV1beta1RecommenderConfig {}
|
|
|
|
|
|
/// A Configuration to customize the generation of recommendations. Eg, customizing the lookback period considered when generating a recommendation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1RecommenderGenerationConfig {
|
|
/// Parameters for this RecommenderGenerationConfig. These configs can be used by or are applied to all subtypes.
|
|
|
|
pub params: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1RecommenderGenerationConfig {}
|
|
|
|
|
|
/// Contains information on the impact of a reliability recommendation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1ReliabilityProjection {
|
|
/// Per-recommender projection.
|
|
|
|
pub details: Option<HashMap<String, json::Value>>,
|
|
/// Reliability risks mitigated by this recommendation.
|
|
|
|
pub risks: Option<Vec<String>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1ReliabilityProjection {}
|
|
|
|
|
|
/// Contains various ways of describing the impact on Security.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1SecurityProjection {
|
|
/// This field can be used by the recommender to define details specific to security impact.
|
|
|
|
pub details: Option<HashMap<String, json::Value>>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1SecurityProjection {}
|
|
|
|
|
|
/// Contains metadata about how much sustainability a recommendation can save or incur.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1SustainabilityProjection {
|
|
/// Duration for which this sustanability applies.
|
|
|
|
#[serde_as(as = "Option<::client::serde::duration::Wrapper>")]
|
|
pub duration: Option<client::chrono::Duration>,
|
|
/// Carbon Footprint generated in kg of CO2 equivalent. Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e).
|
|
#[serde(rename="kgCO2e")]
|
|
|
|
pub kg_co2e: Option<f64>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1SustainabilityProjection {}
|
|
|
|
|
|
/// Contains various matching options for values for a GCP resource field.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleCloudRecommenderV1beta1ValueMatcher {
|
|
/// To be used for full regex matching. The regular expression is using the Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be used with RE2::FullMatch
|
|
#[serde(rename="matchesPattern")]
|
|
|
|
pub matches_pattern: Option<String>,
|
|
}
|
|
|
|
impl client::Part for GoogleCloudRecommenderV1beta1ValueMatcher {}
|
|
|
|
|
|
/// Represents an amount of money with its currency type.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[serde_with::serde_as(crate = "::client::serde_with")]
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleTypeMoney {
|
|
/// The three-letter currency code defined in ISO 4217.
|
|
#[serde(rename="currencyCode")]
|
|
|
|
pub currency_code: Option<String>,
|
|
/// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
|
|
|
|
pub nanos: Option<i32>,
|
|
/// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
|
|
|
|
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
|
pub units: Option<i64>,
|
|
}
|
|
|
|
impl client::Part for GoogleTypeMoney {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *billingAccount* resources.
|
|
/// It is not used directly, but through the [`Recommender`] hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
///
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.billing_accounts();
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountMethods<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
}
|
|
|
|
impl<'a, S> client::MethodsBuilder for BillingAccountMethods<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountMethods<'a, S> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_get(&self, name: &str) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S> {
|
|
BillingAccountLocationInsightTypeInsightGetCall {
|
|
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:
|
|
///
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
pub fn locations_insight_types_insights_list(&self, parent: &str) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
BillingAccountLocationInsightTypeInsightListCall {
|
|
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:
|
|
///
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_mark_accepted(&self, request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest, name: &str) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
BillingAccountLocationInsightTypeInsightMarkAcceptedCall {
|
|
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:
|
|
///
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
pub fn locations_insight_types_get_config(&self, name: &str) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S> {
|
|
BillingAccountLocationInsightTypeGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
pub fn locations_insight_types_update_config(&self, request: GoogleCloudRecommenderV1beta1InsightTypeConfig, name: &str) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
BillingAccountLocationInsightTypeUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_get(&self, name: &str) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationGetCall {
|
|
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:
|
|
///
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
pub fn locations_recommenders_recommendations_list(&self, parent: &str) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationListCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_claimed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest, name: &str) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationMarkClaimedCall {
|
|
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:
|
|
///
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_dismissed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest, name: &str) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationMarkDismissedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_failed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest, name: &str) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationMarkFailedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_succeeded(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest, name: &str) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
BillingAccountLocationRecommenderRecommendationMarkSucceededCall {
|
|
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:
|
|
///
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
pub fn locations_recommenders_get_config(&self, name: &str) -> BillingAccountLocationRecommenderGetConfigCall<'a, S> {
|
|
BillingAccountLocationRecommenderGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
pub fn locations_recommenders_update_config(&self, request: GoogleCloudRecommenderV1beta1RecommenderConfig, name: &str) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
BillingAccountLocationRecommenderUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *folder* resources.
|
|
/// It is not used directly, but through the [`Recommender`] hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
///
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)` and `locations_recommenders_recommendations_mark_succeeded(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.folders();
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderMethods<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
}
|
|
|
|
impl<'a, S> client::MethodsBuilder for FolderMethods<'a, S> {}
|
|
|
|
impl<'a, S> FolderMethods<'a, S> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_get(&self, name: &str) -> FolderLocationInsightTypeInsightGetCall<'a, S> {
|
|
FolderLocationInsightTypeInsightGetCall {
|
|
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:
|
|
///
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
pub fn locations_insight_types_insights_list(&self, parent: &str) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
FolderLocationInsightTypeInsightListCall {
|
|
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:
|
|
///
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_mark_accepted(&self, request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest, name: &str) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
FolderLocationInsightTypeInsightMarkAcceptedCall {
|
|
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:
|
|
///
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_get(&self, name: &str) -> FolderLocationRecommenderRecommendationGetCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationGetCall {
|
|
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:
|
|
///
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
pub fn locations_recommenders_recommendations_list(&self, parent: &str) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationListCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_claimed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest, name: &str) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationMarkClaimedCall {
|
|
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:
|
|
///
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_dismissed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest, name: &str) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationMarkDismissedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_failed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest, name: &str) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationMarkFailedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_succeeded(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest, name: &str) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
FolderLocationRecommenderRecommendationMarkSucceededCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *organization* resources.
|
|
/// It is not used directly, but through the [`Recommender`] hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
///
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.organizations();
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationMethods<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
}
|
|
|
|
impl<'a, S> client::MethodsBuilder for OrganizationMethods<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationMethods<'a, S> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_get(&self, name: &str) -> OrganizationLocationInsightTypeInsightGetCall<'a, S> {
|
|
OrganizationLocationInsightTypeInsightGetCall {
|
|
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:
|
|
///
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
pub fn locations_insight_types_insights_list(&self, parent: &str) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
OrganizationLocationInsightTypeInsightListCall {
|
|
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:
|
|
///
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_mark_accepted(&self, request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest, name: &str) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
OrganizationLocationInsightTypeInsightMarkAcceptedCall {
|
|
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:
|
|
///
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
pub fn locations_insight_types_get_config(&self, name: &str) -> OrganizationLocationInsightTypeGetConfigCall<'a, S> {
|
|
OrganizationLocationInsightTypeGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
pub fn locations_insight_types_update_config(&self, request: GoogleCloudRecommenderV1beta1InsightTypeConfig, name: &str) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
OrganizationLocationInsightTypeUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_get(&self, name: &str) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationGetCall {
|
|
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:
|
|
///
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
pub fn locations_recommenders_recommendations_list(&self, parent: &str) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationListCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_claimed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest, name: &str) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationMarkClaimedCall {
|
|
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:
|
|
///
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_dismissed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest, name: &str) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationMarkDismissedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_failed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest, name: &str) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationMarkFailedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_succeeded(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest, name: &str) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
OrganizationLocationRecommenderRecommendationMarkSucceededCall {
|
|
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:
|
|
///
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
pub fn locations_recommenders_get_config(&self, name: &str) -> OrganizationLocationRecommenderGetConfigCall<'a, S> {
|
|
OrganizationLocationRecommenderGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
pub fn locations_recommenders_update_config(&self, request: GoogleCloudRecommenderV1beta1RecommenderConfig, name: &str) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
OrganizationLocationRecommenderUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *project* resources.
|
|
/// It is not used directly, but through the [`Recommender`] hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
///
|
|
/// # async fn dox() {
|
|
/// use std::default::Default;
|
|
/// use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// secret,
|
|
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// ).build().await.unwrap();
|
|
/// let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `locations_insight_types_get_config(...)`, `locations_insight_types_insights_get(...)`, `locations_insight_types_insights_list(...)`, `locations_insight_types_insights_mark_accepted(...)`, `locations_insight_types_update_config(...)`, `locations_recommenders_get_config(...)`, `locations_recommenders_recommendations_get(...)`, `locations_recommenders_recommendations_list(...)`, `locations_recommenders_recommendations_mark_claimed(...)`, `locations_recommenders_recommendations_mark_dismissed(...)`, `locations_recommenders_recommendations_mark_failed(...)`, `locations_recommenders_recommendations_mark_succeeded(...)` and `locations_recommenders_update_config(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.projects();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectMethods<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
}
|
|
|
|
impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
|
|
|
|
impl<'a, S> ProjectMethods<'a, S> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_get(&self, name: &str) -> ProjectLocationInsightTypeInsightGetCall<'a, S> {
|
|
ProjectLocationInsightTypeInsightGetCall {
|
|
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:
|
|
///
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
pub fn locations_insight_types_insights_list(&self, parent: &str) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
ProjectLocationInsightTypeInsightListCall {
|
|
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:
|
|
///
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the insight.
|
|
pub fn locations_insight_types_insights_mark_accepted(&self, request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest, name: &str) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
ProjectLocationInsightTypeInsightMarkAcceptedCall {
|
|
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:
|
|
///
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
pub fn locations_insight_types_get_config(&self, name: &str) -> ProjectLocationInsightTypeGetConfigCall<'a, S> {
|
|
ProjectLocationInsightTypeGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
pub fn locations_insight_types_update_config(&self, request: GoogleCloudRecommenderV1beta1InsightTypeConfig, name: &str) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
ProjectLocationInsightTypeUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_get(&self, name: &str) -> ProjectLocationRecommenderRecommendationGetCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationGetCall {
|
|
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:
|
|
///
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
pub fn locations_recommenders_recommendations_list(&self, parent: &str) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationListCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_claimed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest, name: &str) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationMarkClaimedCall {
|
|
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:
|
|
///
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_dismissed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest, name: &str) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationMarkDismissedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_failed(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest, name: &str) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationMarkFailedCall {
|
|
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:
|
|
///
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. Name of the recommendation.
|
|
pub fn locations_recommenders_recommendations_mark_succeeded(&self, request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest, name: &str) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
ProjectLocationRecommenderRecommendationMarkSucceededCall {
|
|
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:
|
|
///
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
pub fn locations_recommenders_get_config(&self, name: &str) -> ProjectLocationRecommenderGetConfigCall<'a, S> {
|
|
ProjectLocationRecommenderGetConfigCall {
|
|
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:
|
|
///
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
pub fn locations_recommenders_update_config(&self, request: GoogleCloudRecommenderV1beta1RecommenderConfig, name: &str) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
ProjectLocationRecommenderUpdateConfigCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_validate_only: Default::default(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_additional_params: Default::default(),
|
|
_scopes: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.get* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_insight_types_insights_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationInsightTypeInsightGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationInsightTypeInsightGetCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationInsightTypeInsightGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.insightTypes.insights.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationInsightTypeInsightGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.list* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_insight_types_insights_list("parent")
|
|
/// .page_token("At")
|
|
/// .page_size(-8)
|
|
/// .filter("sed")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationInsightTypeInsightListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationInsightTypeInsightListCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationInsightTypeInsightListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListInsightsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.insightTypes.insights.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(client::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() + "v1beta1/{+parent}/insights";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
///
|
|
/// 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) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationInsightTypeInsightListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationInsightTypeInsightListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationInsightTypeInsightListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationInsightTypeInsightListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::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.billing_accounts().locations_insight_types_insights_mark_accepted(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.insightTypes.insights.markAccepted",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markAccepted";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// A builder for the *locations.insightTypes.getConfig* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_insight_types_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationInsightTypeGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationInsightTypeGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationInsightTypeGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.insightTypes.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
///
|
|
/// 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) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationInsightTypeGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.insightTypes.updateConfig* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1InsightTypeConfig::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.billing_accounts().locations_insight_types_update_config(req, "name")
|
|
/// .validate_only(true)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.insightTypes.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1InsightTypeConfig) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
///
|
|
/// 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) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.get* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_recommenders_recommendations_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationGetCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.list* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_recommenders_recommendations_list("parent")
|
|
/// .page_token("gubergren")
|
|
/// .page_size(-75)
|
|
/// .filter("dolor")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationListCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListRecommendationsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.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(client::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() + "v1beta1/{+parent}/recommendations";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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.billing_accounts().locations_recommenders_recommendations_mark_claimed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.markClaimed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markClaimed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::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.billing_accounts().locations_recommenders_recommendations_mark_dismissed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.markDismissed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markDismissed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the recommendation.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::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.billing_accounts().locations_recommenders_recommendations_mark_failed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.markFailed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markFailed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::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.billing_accounts().locations_recommenders_recommendations_mark_succeeded(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.recommendations.markSucceeded",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markSucceeded";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.getConfig* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.billing_accounts().locations_recommenders_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.recommenders.updateConfig* method supported by a *billingAccount* resource.
|
|
/// It is not used directly, but through a [`BillingAccountMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1RecommenderConfig::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.billing_accounts().locations_recommenders_update_config(req, "name")
|
|
/// .validate_only(false)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct BillingAccountLocationRecommenderUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1RecommenderConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> BillingAccountLocationRecommenderUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.billingAccounts.locations.recommenders.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1RecommenderConfig) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
///
|
|
/// 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) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> BillingAccountLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.get* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.folders().locations_insight_types_insights_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationInsightTypeInsightGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationInsightTypeInsightGetCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationInsightTypeInsightGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.insightTypes.insights.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> FolderLocationInsightTypeInsightGetCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationInsightTypeInsightGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationInsightTypeInsightGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.list* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.folders().locations_insight_types_insights_list("parent")
|
|
/// .page_token("rebum.")
|
|
/// .page_size(-57)
|
|
/// .filter("ipsum")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationInsightTypeInsightListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationInsightTypeInsightListCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationInsightTypeInsightListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListInsightsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.insightTypes.insights.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(client::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() + "v1beta1/{+parent}/insights";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
///
|
|
/// 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) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationInsightTypeInsightListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::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.folders().locations_insight_types_insights_mark_accepted(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.insightTypes.insights.markAccepted",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markAccepted";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.get* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.folders().locations_recommenders_recommendations_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationGetCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.list* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.folders().locations_recommenders_recommendations_list("parent")
|
|
/// .page_token("ea")
|
|
/// .page_size(-99)
|
|
/// .filter("Lorem")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationListCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListRecommendationsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.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(client::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() + "v1beta1/{+parent}/recommendations";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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.folders().locations_recommenders_recommendations_mark_claimed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.markClaimed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markClaimed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::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.folders().locations_recommenders_recommendations_mark_dismissed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.markDismissed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markDismissed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the recommendation.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::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.folders().locations_recommenders_recommendations_mark_failed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.markFailed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markFailed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *folder* resource.
|
|
/// It is not used directly, but through a [`FolderMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::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.folders().locations_recommenders_recommendations_mark_succeeded(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {}
|
|
|
|
impl<'a, S> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.folders.locations.recommenders.recommendations.markSucceeded",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markSucceeded";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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 client::Delegate) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> FolderLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.get* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_insight_types_insights_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationInsightTypeInsightGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationInsightTypeInsightGetCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationInsightTypeInsightGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.insightTypes.insights.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> OrganizationLocationInsightTypeInsightGetCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationInsightTypeInsightGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationInsightTypeInsightGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationInsightTypeInsightGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationInsightTypeInsightGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationInsightTypeInsightGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.list* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_insight_types_insights_list("parent")
|
|
/// .page_token("Stet")
|
|
/// .page_size(-13)
|
|
/// .filter("et")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationInsightTypeInsightListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationInsightTypeInsightListCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationInsightTypeInsightListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListInsightsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.insightTypes.insights.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(client::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() + "v1beta1/{+parent}/insights";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
///
|
|
/// 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) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationInsightTypeInsightListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationInsightTypeInsightListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationInsightTypeInsightListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationInsightTypeInsightListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::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.organizations().locations_insight_types_insights_mark_accepted(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.insightTypes.insights.markAccepted",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markAccepted";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// A builder for the *locations.insightTypes.getConfig* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_insight_types_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationInsightTypeGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationInsightTypeGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationInsightTypeGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.insightTypes.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
///
|
|
/// 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) -> OrganizationLocationInsightTypeGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationInsightTypeGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationInsightTypeGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationInsightTypeGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationInsightTypeGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationInsightTypeGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.insightTypes.updateConfig* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1InsightTypeConfig::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.organizations().locations_insight_types_update_config(req, "name")
|
|
/// .validate_only(false)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.insightTypes.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1InsightTypeConfig) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
///
|
|
/// 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) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.get* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_recommenders_recommendations_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationGetCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.list* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_recommenders_recommendations_list("parent")
|
|
/// .page_token("duo")
|
|
/// .page_size(-34)
|
|
/// .filter("et")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationListCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListRecommendationsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.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(client::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() + "v1beta1/{+parent}/recommendations";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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.organizations().locations_recommenders_recommendations_mark_claimed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.markClaimed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markClaimed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::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.organizations().locations_recommenders_recommendations_mark_dismissed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.markDismissed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markDismissed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the recommendation.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::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.organizations().locations_recommenders_recommendations_mark_failed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.markFailed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markFailed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::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.organizations().locations_recommenders_recommendations_mark_succeeded(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.recommendations.markSucceeded",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markSucceeded";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.getConfig* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.organizations().locations_recommenders_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> OrganizationLocationRecommenderGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.recommenders.updateConfig* method supported by a *organization* resource.
|
|
/// It is not used directly, but through a [`OrganizationMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1RecommenderConfig::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.organizations().locations_recommenders_update_config(req, "name")
|
|
/// .validate_only(false)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct OrganizationLocationRecommenderUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1RecommenderConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for OrganizationLocationRecommenderUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> OrganizationLocationRecommenderUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.organizations.locations.recommenders.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1RecommenderConfig) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
///
|
|
/// 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) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> OrganizationLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_insight_types_insights_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationInsightTypeInsightGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationInsightTypeInsightGetCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationInsightTypeInsightGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.insightTypes.insights.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> ProjectLocationInsightTypeInsightGetCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationInsightTypeInsightGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeInsightGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationInsightTypeInsightGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_insight_types_insights_list("parent")
|
|
/// .page_token("duo")
|
|
/// .page_size(-76)
|
|
/// .filter("vero")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationInsightTypeInsightListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationInsightTypeInsightListCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationInsightTypeInsightListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListInsightsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.insightTypes.insights.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(client::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() + "v1beta1/{+parent}/insights";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types.
|
|
///
|
|
/// 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) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Optional. Filter expression to restrict the insights returned. Supported filter fields: * `stateInfo.state` * `insightSubtype` * `severity` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `insightSubtype = PERMISSIONS_USAGE` * `severity = CRITICAL OR severity = HIGH` * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeInsightListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationInsightTypeInsightListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated. MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
|
|
///
|
|
/// A builder for the *locations.insightTypes.insights.markAccepted* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest::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.projects().locations_insight_types_insights_mark_accepted(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Insight)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.insightTypes.insights.markAccepted",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markAccepted";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkInsightAcceptedRequest) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the insight.
|
|
///
|
|
/// 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) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationInsightTypeInsightMarkAcceptedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
|
|
///
|
|
/// A builder for the *locations.insightTypes.getConfig* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_insight_types_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationInsightTypeGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationInsightTypeGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationInsightTypeGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.insightTypes.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the InsightTypeConfig to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
|
|
///
|
|
/// 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) -> ProjectLocationInsightTypeGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationInsightTypeGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationInsightTypeGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationInsightTypeGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates an InsightTypeConfig change. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.insightTypes.updateConfig* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1InsightTypeConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1InsightTypeConfig::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.projects().locations_insight_types_update_config(req, "name")
|
|
/// .validate_only(true)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1InsightTypeConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationInsightTypeUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1InsightTypeConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.insightTypes.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1InsightTypeConfig) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of insight type config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
|
|
///
|
|
/// 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) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationInsightTypeUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_recommenders_recommendations_get("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationGetCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationGetCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationGetCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.get",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationGetCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationGetCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationGetCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationGetCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationGetCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_recommenders_recommendations_list("parent")
|
|
/// .page_token("no")
|
|
/// .page_size(-100)
|
|
/// .filter("accusam")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationListCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationListCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationListCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1ListRecommendationsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.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(client::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() + "v1beta1/{+parent}/recommendations";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The container resource on which to execute the request. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]` LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional. If present, retrieves the next batch of results from the preceding call to this method. `page_token` must be the value of `next_page_token` from the previous response. The values of other method parameters must be identical to those in the previous call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional. The maximum number of results to return from this request. Non-positive values are ignored. If not specified, the server will determine the number of results to return.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Filter expression to restrict the recommendations returned. Supported filter fields: * `state_info.state` * `recommenderSubtype` * `priority` Examples: * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED` * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE` * `priority = P1 OR priority = P2` * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)` (These expressions are based on the filter language described at https://google.aip.dev/160)
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationListCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationListCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationListCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationListCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationClaimed can be applied to recommendations in CLAIMED or ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markClaimed* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest::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.projects().locations_recommenders_recommendations_mark_claimed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.markClaimed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markClaimed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationClaimedRequest) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationMarkClaimedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED. MarkRecommendationDismissed can be applied to recommendations in ACTIVE state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markDismissed* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest::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.projects().locations_recommenders_recommendations_mark_dismissed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.markDismissed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markDismissed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationDismissedRequest) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the recommendation.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationMarkDismissedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markFailed* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest::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.projects().locations_recommenders_recommendations_mark_failed(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.markFailed",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markFailed";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationFailedRequest) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationMarkFailedCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state. MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state. Requires the recommender.*.update IAM permission for the specified recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.recommendations.markSucceeded* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest::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.projects().locations_recommenders_recommendations_mark_succeeded(req, "name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1Recommendation)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.recommendations.markSucceeded",
|
|
http_method: hyper::Method::POST });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}:markSucceeded";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1MarkRecommendationSucceededRequest) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. Name of the recommendation.
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderRecommendationMarkSucceededCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
|
|
///
|
|
/// A builder for the *locations.recommenders.getConfig* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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.projects().locations_recommenders_get_config("name")
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderGetConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderGetConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderGetConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.getConfig",
|
|
http_method: hyper::Method::GET });
|
|
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::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() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::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
|
|
.body(hyper::body::Body::empty());
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. Name of the Recommendation Config to get. Acceptable formats: * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config` * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderGetConfigCall<'a, S> {
|
|
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 client::Delegate) -> ProjectLocationRecommenderGetConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderGetConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderGetConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderGetConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderGetConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a Recommender Config. This will create a new revision of the config.
|
|
///
|
|
/// A builder for the *locations.recommenders.updateConfig* method supported by a *project* resource.
|
|
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate google_recommender1_beta1 as recommender1_beta1;
|
|
/// use recommender1_beta1::api::GoogleCloudRecommenderV1beta1RecommenderConfig;
|
|
/// # async fn dox() {
|
|
/// # use std::default::Default;
|
|
/// # use recommender1_beta1::{Recommender, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
|
///
|
|
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
|
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
|
/// # secret,
|
|
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
/// # ).build().await.unwrap();
|
|
/// # let mut hub = Recommender::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), 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 = GoogleCloudRecommenderV1beta1RecommenderConfig::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.projects().locations_recommenders_update_config(req, "name")
|
|
/// .validate_only(true)
|
|
/// .update_mask(&Default::default())
|
|
/// .doit().await;
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationRecommenderUpdateConfigCall<'a, S>
|
|
where S: 'a {
|
|
|
|
hub: &'a Recommender<S>,
|
|
_request: GoogleCloudRecommenderV1beta1RecommenderConfig,
|
|
_name: String,
|
|
_validate_only: Option<bool>,
|
|
_update_mask: Option<client::FieldMask>,
|
|
_delegate: Option<&'a mut dyn client::Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeSet<String>
|
|
}
|
|
|
|
impl<'a, S> client::CallBuilder for ProjectLocationRecommenderUpdateConfigCall<'a, S> {}
|
|
|
|
impl<'a, S> ProjectLocationRecommenderUpdateConfigCall<'a, S>
|
|
where
|
|
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
|
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
|
S::Future: Send + Unpin + 'static,
|
|
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
|
{
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GoogleCloudRecommenderV1beta1RecommenderConfig)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
|
use client::{ToParts, url::Params};
|
|
use std::borrow::Cow;
|
|
|
|
let mut dd = client::DefaultDelegate;
|
|
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
|
dlg.begin(client::MethodInfo { id: "recommender.projects.locations.recommenders.updateConfig",
|
|
http_method: hyper::Method::PATCH });
|
|
|
|
for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(client::Error::FieldClash(field));
|
|
}
|
|
}
|
|
|
|
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
|
params.push("name", self._name);
|
|
if let Some(value) = self._validate_only.as_ref() {
|
|
params.push("validateOnly", value.to_string());
|
|
}
|
|
if let Some(value) = self._update_mask.as_ref() {
|
|
params.push("updateMask", value.to_string());
|
|
}
|
|
|
|
params.extend(self._additional_params.iter());
|
|
|
|
params.push("alt", "json");
|
|
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
|
if self._scopes.is_empty() {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
|
}
|
|
|
|
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 = json::value::to_value(&self._request).expect("serde to work");
|
|
client::remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
match dlg.token(e) {
|
|
Ok(token) => token,
|
|
Err(e) => {
|
|
dlg.finished(false);
|
|
return Err(client::Error::MissingToken(e));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
request_value_reader.seek(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::PATCH)
|
|
.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(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
|
|
|
client.request(request.unwrap()).await
|
|
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let client::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(client::Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status().is_success() {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
let (parts, _) = res.into_parts();
|
|
let body = hyper::Body::from(res_body_string.clone());
|
|
let restored_response = hyper::Response::from_parts(parts, body);
|
|
|
|
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
|
|
|
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
|
sleep(d).await;
|
|
continue;
|
|
}
|
|
|
|
dlg.finished(false);
|
|
|
|
return match server_response {
|
|
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
|
None => Err(client::Error::Failure(restored_response)),
|
|
}
|
|
}
|
|
let result_value = {
|
|
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
|
|
|
match json::from_str(&res_body_string) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&res_body_string, &err);
|
|
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// 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: GoogleCloudRecommenderV1beta1RecommenderConfig) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of recommender config. Eg, projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
|
|
///
|
|
/// 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) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// If true, validate the request and preview the change, but do not actually update it.
|
|
///
|
|
/// Sets the *validate only* query property to the given value.
|
|
pub fn validate_only(mut self, new_value: bool) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._validate_only = Some(new_value);
|
|
self
|
|
}
|
|
/// The list of fields to be updated.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._update_mask = Some(new_value);
|
|
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 client::Delegate) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
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<T>(mut self, name: T, value: T) -> ProjectLocationRecommenderUpdateConfigCall<'a, S>
|
|
where T: AsRef<str> {
|
|
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::CloudPlatform`].
|
|
///
|
|
/// 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<St>(mut self, scope: St) -> ProjectLocationRecommenderUpdateConfigCall<'a, S>
|
|
where St: AsRef<str> {
|
|
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<I, St>(mut self, scopes: I) -> ProjectLocationRecommenderUpdateConfigCall<'a, S>
|
|
where I: IntoIterator<Item = St>,
|
|
St: AsRef<str> {
|
|
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) -> ProjectLocationRecommenderUpdateConfigCall<'a, S> {
|
|
self._scopes.clear();
|
|
self
|
|
}
|
|
}
|
|
|
|
|