pub struct Client { /* private fields */ }Expand description
Client for Cost Optimization Hub
Client for invoking operations on Cost Optimization Hub. Each operation on Cost Optimization Hub is a method on this
this struct. .send() MUST be invoked on the generated operations to dispatch the request to the service.
§Constructing a Client
A Config is required to construct a client. For most use cases, the aws-config
crate should be used to automatically resolve this config using
aws_config::load_from_env(), since this will resolve an SdkConfig which can be shared
across multiple different AWS SDK clients. This config resolution process can be customized
by calling aws_config::from_env() instead, which returns a ConfigLoader that uses
the builder pattern to customize the default config.
In the simplest case, creating a client looks as follows:
let config = aws_config::load_from_env().await;
let client = aws_sdk_costoptimizationhub::Client::new(&config);Occasionally, SDKs may have additional service-specific values that can be set on the Config that
is absent from SdkConfig, or slightly different settings for a specific client may be desired.
The Builder struct implements From<&SdkConfig>, so setting these specific settings can be
done as follows:
let sdk_config = ::aws_config::load_from_env().await;
let config = aws_sdk_costoptimizationhub::config::Builder::from(&sdk_config)
.some_service_specific_setting("value")
.build();See the aws-config docs and Config for more information on customizing configuration.
Note: Client construction is expensive due to connection thread pool initialization, and should be done once at application start-up.
§Using the Client
A client has a function for every operation that can be performed by the service.
For example, the GetRecommendation operation has
a Client::get_recommendation, function which returns a builder for that operation.
The fluent builder ultimately has a send() function that returns an async future that
returns a result, as illustrated below:
let result = client.get_recommendation()
.recommendation_id("example")
.send()
.await;The underlying HTTP requests that get made by this can be modified with the customize_operation
function on the fluent builder. See the customize module for more
information.
Implementations§
Source§impl Client
impl Client
Sourcepub fn get_preferences(&self) -> GetPreferencesFluentBuilder
pub fn get_preferences(&self) -> GetPreferencesFluentBuilder
Constructs a fluent builder for the GetPreferences operation.
- The fluent builder takes no input, just
sendit. - On success, responds with
GetPreferencesOutputwith field(s):savings_estimation_mode(Option<SavingsEstimationMode>):Retrieves the status of the “savings estimation mode” preference.
member_account_discount_visibility(Option<MemberAccountDiscountVisibility>):Retrieves the status of the “member account discount visibility” preference.
preferred_commitment(Option<PreferredCommitment>):Retrieves the current preferences for how Reserved Instances and Savings Plans cost-saving opportunities are prioritized in terms of payment option and term length.
- On failure, responds with
SdkError<GetPreferencesError>
Source§impl Client
impl Client
Sourcepub fn get_recommendation(&self) -> GetRecommendationFluentBuilder
pub fn get_recommendation(&self) -> GetRecommendationFluentBuilder
Constructs a fluent builder for the GetRecommendation operation.
- The fluent builder is configurable:
recommendation_id(impl Into<String>)/set_recommendation_id(Option<String>):
required: trueThe ID for the recommendation.
- On success, responds with
GetRecommendationOutputwith field(s):recommendation_id(Option<String>):The ID for the recommendation.
resource_id(Option<String>):The unique identifier for the resource. This is the same as the Amazon Resource Name (ARN), if available.
resource_arn(Option<String>):The Amazon Resource Name (ARN) of the resource.
account_id(Option<String>):The account to which the recommendation applies.
currency_code(Option<String>):The currency code used for the recommendation.
recommendation_lookback_period_in_days(Option<i32>):The lookback period that’s used to generate the recommendation.
cost_calculation_lookback_period_in_days(Option<i32>):The lookback period used to calculate cost impact for a recommendation.
estimated_savings_percentage(Option<f64>):The estimated savings percentage relative to the total cost over the cost calculation lookback period.
estimated_savings_over_cost_calculation_lookback_period(Option<f64>):The estimated savings amount over the lookback period used to calculate cost impact for a recommendation.
current_resource_type(Option<ResourceType>):The type of resource.
recommended_resource_type(Option<ResourceType>):The resource type of the recommendation.
region(Option<String>):The Amazon Web Services Region of the resource.
source(Option<Source>):The source of the recommendation.
last_refresh_timestamp(Option<DateTime>):The time when the recommendation was last generated.
estimated_monthly_savings(Option<f64>):The estimated monthly savings amount for the recommendation.
estimated_monthly_cost(Option<f64>):The estimated monthly cost of the current resource. For Reserved Instances and Savings Plans, it refers to the cost for eligible usage.
implementation_effort(Option<ImplementationEffort>):The effort required to implement the recommendation.
restart_needed(Option<bool>):Whether or not implementing the recommendation requires a restart.
action_type(Option<ActionType>):The type of action you can take by adopting the recommendation.
rollback_possible(Option<bool>):Whether or not implementing the recommendation can be rolled back.
current_resource_details(Option<ResourceDetails>):The details for the resource.
recommended_resource_details(Option<ResourceDetails>):The details about the recommended resource.
tags(Option<Vec::<Tag>>):A list of tags associated with the resource for which the recommendation exists.
- On failure, responds with
SdkError<GetRecommendationError>
Source§impl Client
impl Client
Sourcepub fn list_efficiency_metrics(&self) -> ListEfficiencyMetricsFluentBuilder
pub fn list_efficiency_metrics(&self) -> ListEfficiencyMetricsFluentBuilder
Constructs a fluent builder for the ListEfficiencyMetrics operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
group_by(impl Into<String>)/set_group_by(Option<String>):
required: falseThe dimension by which to group the cost efficiency metrics. Valid values include account ID, Amazon Web Services Region. When no grouping is specified, metrics are aggregated across all resources in the specified time period.
granularity(GranularityType)/set_granularity(Option<GranularityType>):
required: trueThe time granularity for the cost efficiency metrics. Specify
Dailyfor metrics aggregated by day, orMonthlyfor metrics aggregated by month.time_period(TimePeriod)/set_time_period(Option<TimePeriod>):
required: trueThe time period for which to retrieve the cost efficiency metrics. The start date is inclusive and the end date is exclusive. Dates can be specified in either YYYY-MM-DD format or YYYY-MM format depending on the desired granularity.
max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of groups to return in the response. Valid values range from 0 to 1000. Use in conjunction with
nextTokento paginate through results when the total number of groups exceeds this limit.order_by(OrderBy)/set_order_by(Option<OrderBy>):
required: falseThe ordering specification for the results. Defines which dimension to sort by and whether to sort in ascending or descending order.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token to retrieve the next page of results. This value is returned in the response when the number of groups exceeds the specified
maxResultsvalue.
- On success, responds with
ListEfficiencyMetricsOutputwith field(s):efficiency_metrics_by_group(Option<Vec::<EfficiencyMetricsByGroup>>):A list of cost efficiency metrics grouped by the specified dimension. Each group contains time-series data points with cost efficiency, potential savings, and optimzable spend for the specified time period.
next_token(Option<String>):The token to retrieve the next page of results. When this value is present in the response, additional groups are available. Pass this token in the
nextTokenparameter of a subsequent request to retrieve the next page.
- On failure, responds with
SdkError<ListEfficiencyMetricsError>
Source§impl Client
impl Client
Sourcepub fn list_enrollment_statuses(&self) -> ListEnrollmentStatusesFluentBuilder
pub fn list_enrollment_statuses(&self) -> ListEnrollmentStatusesFluentBuilder
Constructs a fluent builder for the ListEnrollmentStatuses operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
include_organization_info(bool)/set_include_organization_info(Option<bool>):
required: falseIndicates whether to return the enrollment status for the organization.
account_id(impl Into<String>)/set_account_id(Option<String>):
required: falseThe account ID of a member account in the organization.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token to retrieve the next set of results.
max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of objects that are returned for the request.
- On success, responds with
ListEnrollmentStatusesOutputwith field(s):items(Option<Vec::<AccountEnrollmentStatus>>):The enrollment status of a specific account ID, including creation and last updated timestamps.
include_member_accounts(Option<bool>):The enrollment status of all member accounts in the organization if the account is the management account or delegated administrator.
next_token(Option<String>):The token to retrieve the next set of results.
- On failure, responds with
SdkError<ListEnrollmentStatusesError>
Source§impl Client
impl Client
Sourcepub fn list_recommendation_summaries(
&self,
) -> ListRecommendationSummariesFluentBuilder
pub fn list_recommendation_summaries( &self, ) -> ListRecommendationSummariesFluentBuilder
Constructs a fluent builder for the ListRecommendationSummaries operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
filter(Filter)/set_filter(Option<Filter>):
required: falseDescribes a filter that returns a more specific list of recommendations. Filters recommendations by different dimensions.
group_by(impl Into<String>)/set_group_by(Option<String>):
required: trueThe grouping of recommendations by a dimension.
max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of recommendations to be returned for the request.
metrics(SummaryMetrics)/set_metrics(Option<Vec::<SummaryMetrics>>):
required: falseAdditional metrics to be returned for the request. The only valid value is
savingsPercentage.next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token to retrieve the next set of results.
- On success, responds with
ListRecommendationSummariesOutputwith field(s):estimated_total_deduped_savings(Option<f64>):The total overall savings for the aggregated view.
items(Option<Vec::<RecommendationSummary>>):A list of all savings recommendations.
group_by(Option<String>):The dimension used to group the recommendations by.
currency_code(Option<String>):The currency code used for the recommendation.
metrics(Option<SummaryMetricsResult>):The results or descriptions for the additional metrics, based on whether the metrics were or were not requested.
next_token(Option<String>):The token to retrieve the next set of results.
- On failure, responds with
SdkError<ListRecommendationSummariesError>
Source§impl Client
impl Client
Sourcepub fn list_recommendations(&self) -> ListRecommendationsFluentBuilder
pub fn list_recommendations(&self) -> ListRecommendationsFluentBuilder
Constructs a fluent builder for the ListRecommendations operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
filter(Filter)/set_filter(Option<Filter>):
required: falseThe constraints that you want all returned recommendations to match.
order_by(OrderBy)/set_order_by(Option<OrderBy>):
required: falseThe ordering of recommendations by a dimension.
include_all_recommendations(bool)/set_include_all_recommendations(Option<bool>):
required: falseList of all recommendations for a resource, or a single recommendation if de-duped by
resourceId.max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of recommendations that are returned for the request.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseThe token to retrieve the next set of results.
- On success, responds with
ListRecommendationsOutputwith field(s):items(Option<Vec::<Recommendation>>):List of all savings recommendations.
next_token(Option<String>):The token to retrieve the next set of results.
- On failure, responds with
SdkError<ListRecommendationsError>
Source§impl Client
impl Client
Sourcepub fn update_enrollment_status(&self) -> UpdateEnrollmentStatusFluentBuilder
pub fn update_enrollment_status(&self) -> UpdateEnrollmentStatusFluentBuilder
Constructs a fluent builder for the UpdateEnrollmentStatus operation.
- The fluent builder is configurable:
status(EnrollmentStatus)/set_status(Option<EnrollmentStatus>):
required: trueSets the account status.
include_member_accounts(bool)/set_include_member_accounts(Option<bool>):
required: falseIndicates whether to enroll member accounts of the organization if the account is the management account or delegated administrator.
- On success, responds with
UpdateEnrollmentStatusOutputwith field(s):status(Option<String>):The enrollment status of the account.
- On failure, responds with
SdkError<UpdateEnrollmentStatusError>
Source§impl Client
impl Client
Sourcepub fn update_preferences(&self) -> UpdatePreferencesFluentBuilder
pub fn update_preferences(&self) -> UpdatePreferencesFluentBuilder
Constructs a fluent builder for the UpdatePreferences operation.
- The fluent builder is configurable:
savings_estimation_mode(SavingsEstimationMode)/set_savings_estimation_mode(Option<SavingsEstimationMode>):
required: falseSets the “savings estimation mode” preference.
member_account_discount_visibility(MemberAccountDiscountVisibility)/set_member_account_discount_visibility(Option<MemberAccountDiscountVisibility>):
required: falseSets the “member account discount visibility” preference.
preferred_commitment(PreferredCommitment)/set_preferred_commitment(Option<PreferredCommitment>):
required: falseSets the preferences for how Reserved Instances and Savings Plans cost-saving opportunities are prioritized in terms of payment option and term length.
- On success, responds with
UpdatePreferencesOutputwith field(s):savings_estimation_mode(Option<SavingsEstimationMode>):Shows the status of the “savings estimation mode” preference.
member_account_discount_visibility(Option<MemberAccountDiscountVisibility>):Shows the status of the “member account discount visibility” preference.
preferred_commitment(Option<PreferredCommitment>):Shows the updated preferences for how Reserved Instances and Savings Plans cost-saving opportunities are prioritized in terms of payment option and term length.
- On failure, responds with
SdkError<UpdatePreferencesError>
Source§impl Client
impl Client
Sourcepub fn from_conf(conf: Config) -> Self
pub fn from_conf(conf: Config) -> Self
Creates a new client from the service Config.
§Panics
This method will panic in the following cases:
- Retries or timeouts are enabled without a
sleep_implconfigured. - Identity caching is enabled without a
sleep_implandtime_sourceconfigured. - No
behavior_versionis provided.
The panic message for each of these will have instructions on how to resolve them.
Source§impl Client
impl Client
Sourcepub fn new(sdk_config: &SdkConfig) -> Self
pub fn new(sdk_config: &SdkConfig) -> Self
Creates a new client from an SDK Config.
§Panics
- This method will panic if the
sdk_configis missing an async sleep implementation. If you experience this panic, set thesleep_implon the Config passed into this function to fix it. - This method will panic if the
sdk_configis missing an HTTP connector. If you experience this panic, set thehttp_connectoron the Config passed into this function to fix it. - This method will panic if no
BehaviorVersionis provided. If you experience this panic, setbehavior_versionon the Config or enable thebehavior-version-latestCargo feature.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);