Struct aws_sdk_s3::operation::GetObject
source · pub struct GetObject { /* private fields */ }
Expand description
Operation shape for GetObject
.
This is usually constructed for you using the the fluent builder returned by
get_object
.
See crate::client::fluent_builders::GetObject
for more details about the operation.
Implementations§
source§impl GetObject
impl GetObject
sourcepub fn builder() -> Builder
pub fn builder() -> Builder
Creates a new builder-style object to manufacture GetObjectInput
.
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new GetObject
operation.
Examples found in repository?
src/input.rs (line 10283)
10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534
async fn _make_presigned_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::GetObject,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let mut request = {
fn uri_base(
_input: &crate::input::GetObjectInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_64 = &_input.bucket;
let input_64 = input_64.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"bucket",
"cannot be empty or unset",
)
})?;
let bucket = aws_smithy_http::label::fmt_string(
input_64,
aws_smithy_http::label::EncodingStrategy::Default,
);
if bucket.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"bucket",
"cannot be empty or unset",
),
);
}
let input_65 = &_input.key;
let input_65 = input_65.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"key",
"cannot be empty or unset",
)
})?;
let key = aws_smithy_http::label::fmt_string(
input_65,
aws_smithy_http::label::EncodingStrategy::Greedy,
);
if key.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"key",
"cannot be empty or unset",
),
);
}
write!(output, "/{Bucket}/{Key}", Bucket = bucket, Key = key)
.expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::GetObjectInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
query.push_kv("x-id", "GetObject");
if let Some(inner_66) = &_input.response_cache_control {
{
query.push_kv(
"response-cache-control",
&aws_smithy_http::query::fmt_string(&inner_66),
);
}
}
if let Some(inner_67) = &_input.response_content_disposition {
{
query.push_kv(
"response-content-disposition",
&aws_smithy_http::query::fmt_string(&inner_67),
);
}
}
if let Some(inner_68) = &_input.response_content_encoding {
{
query.push_kv(
"response-content-encoding",
&aws_smithy_http::query::fmt_string(&inner_68),
);
}
}
if let Some(inner_69) = &_input.response_content_language {
{
query.push_kv(
"response-content-language",
&aws_smithy_http::query::fmt_string(&inner_69),
);
}
}
if let Some(inner_70) = &_input.response_content_type {
{
query.push_kv(
"response-content-type",
&aws_smithy_http::query::fmt_string(&inner_70),
);
}
}
if let Some(inner_71) = &_input.response_expires {
{
query.push_kv(
"response-expires",
&aws_smithy_http::query::fmt_timestamp(
inner_71,
aws_smithy_types::date_time::Format::HttpDate,
)?,
);
}
}
if let Some(inner_72) = &_input.version_id {
{
query.push_kv("versionId", &aws_smithy_http::query::fmt_string(&inner_72));
}
}
if _input.part_number != 0 {
query.push_kv(
"partNumber",
aws_smithy_types::primitive::Encoder::from(_input.part_number).encode(),
);
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::GetObjectInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
let builder = crate::http_serde::add_headers_get_object(input, builder)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
if let Some(checksum_mode) = self.checksum_mode.as_ref() {
let checksum_mode = checksum_mode.clone();
// Place crate::model::ChecksumMode in the property bag so we can check
// it during response deserialization to see if we need to checksum validate
// the response body.
let _ = request.properties_mut().insert(checksum_mode);
}
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_options.content_sha256_header = true;
signing_config.signing_options.double_uri_encode = false;
signing_config.signing_options.normalize_uri_path = false;
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
let endpoint_params = aws_endpoint::Params::new(_config.region.clone());
request
.properties_mut()
.insert::<aws_smithy_http::endpoint::Result>(
_config.endpoint_resolver.resolve_endpoint(&endpoint_params),
);
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_provider(
&mut request.properties_mut(),
_config.credentials_provider.clone(),
);
let op =
aws_smithy_http::operation::Operation::new(request, crate::operation::GetObject::new())
.with_metadata(aws_smithy_http::operation::Metadata::new("GetObject", "s3"));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
///
/// Creates a presigned request for this operation.
///
/// The credentials provider from the `config` will be used to generate the request's signature.
/// The `presigning_config` provides additional presigning-specific config values, such as the
/// amount of time the request should be valid for after creation.
///
/// Presigned requests can be given to other users or applications to access a resource or perform
/// an operation without having access to the AWS security credentials.
///
pub async fn presigned(
self,
config: &crate::config::Config,
presigning_config: crate::presigning::config::PresigningConfig,
) -> Result<
crate::presigning::request::PresignedRequest,
aws_smithy_http::result::SdkError<crate::error::GetObjectError>,
> {
let (mut request, _) = self
._make_presigned_operation(config)
.await
.map_err(aws_smithy_http::result::SdkError::construction_failure)?
.into_request_response();
{
// Change signature type to query params and wire up presigning config
let mut props = request.properties_mut();
props.insert(presigning_config.start_time());
props.insert(aws_sigv4::http_request::SignableBody::UnsignedPayload);
let mut config = props
.get_mut::<aws_sig_auth::signer::OperationSigningConfig>()
.expect("signing config added by make_operation()");
config.signature_type = aws_sig_auth::signer::HttpSignatureType::HttpRequestQueryParams;
config.expires_in = Some(presigning_config.expires());
}
let middleware = crate::middleware::DefaultMiddleware::default();
let mut svc = tower::builder::ServiceBuilder::new()
.layer(&middleware)
.service(crate::presigning::service::PresignedRequestService::new());
use tower::{Service, ServiceExt};
Ok(svc.ready().await?.call(request).await?)
}
/// Consumes the builder and constructs an Operation<[`GetObject`](crate::operation::GetObject)>
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::GetObject,
aws_http::retry::AwsResponseRetryClassifier,
>,
aws_smithy_http::operation::error::BuildError,
> {
let mut request = {
fn uri_base(
_input: &crate::input::GetObjectInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let input_73 = &_input.bucket;
let input_73 = input_73.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"bucket",
"cannot be empty or unset",
)
})?;
let bucket = aws_smithy_http::label::fmt_string(
input_73,
aws_smithy_http::label::EncodingStrategy::Default,
);
if bucket.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"bucket",
"cannot be empty or unset",
),
);
}
let input_74 = &_input.key;
let input_74 = input_74.as_ref().ok_or_else(|| {
aws_smithy_http::operation::error::BuildError::missing_field(
"key",
"cannot be empty or unset",
)
})?;
let key = aws_smithy_http::label::fmt_string(
input_74,
aws_smithy_http::label::EncodingStrategy::Greedy,
);
if key.is_empty() {
return Err(
aws_smithy_http::operation::error::BuildError::missing_field(
"key",
"cannot be empty or unset",
),
);
}
write!(output, "/{Bucket}/{Key}", Bucket = bucket, Key = key)
.expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::GetObjectInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::error::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
query.push_kv("x-id", "GetObject");
if let Some(inner_75) = &_input.response_cache_control {
{
query.push_kv(
"response-cache-control",
&aws_smithy_http::query::fmt_string(&inner_75),
);
}
}
if let Some(inner_76) = &_input.response_content_disposition {
{
query.push_kv(
"response-content-disposition",
&aws_smithy_http::query::fmt_string(&inner_76),
);
}
}
if let Some(inner_77) = &_input.response_content_encoding {
{
query.push_kv(
"response-content-encoding",
&aws_smithy_http::query::fmt_string(&inner_77),
);
}
}
if let Some(inner_78) = &_input.response_content_language {
{
query.push_kv(
"response-content-language",
&aws_smithy_http::query::fmt_string(&inner_78),
);
}
}
if let Some(inner_79) = &_input.response_content_type {
{
query.push_kv(
"response-content-type",
&aws_smithy_http::query::fmt_string(&inner_79),
);
}
}
if let Some(inner_80) = &_input.response_expires {
{
query.push_kv(
"response-expires",
&aws_smithy_http::query::fmt_timestamp(
inner_80,
aws_smithy_types::date_time::Format::HttpDate,
)?,
);
}
}
if let Some(inner_81) = &_input.version_id {
{
query.push_kv("versionId", &aws_smithy_http::query::fmt_string(&inner_81));
}
}
if _input.part_number != 0 {
query.push_kv(
"partNumber",
aws_smithy_types::primitive::Encoder::from(_input.part_number).encode(),
);
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::GetObjectInput,
builder: http::request::Builder,
) -> std::result::Result<
http::request::Builder,
aws_smithy_http::operation::error::BuildError,
> {
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
let builder = crate::http_serde::add_headers_get_object(input, builder)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
if let Some(checksum_mode) = self.checksum_mode.as_ref() {
let checksum_mode = checksum_mode.clone();
// Place crate::model::ChecksumMode in the property bag so we can check
// it during response deserialization to see if we need to checksum validate
// the response body.
let _ = request.properties_mut().insert(checksum_mode);
}
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_options.content_sha256_header = true;
signing_config.signing_options.double_uri_encode = false;
signing_config.signing_options.normalize_uri_path = false;
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
if let Some(region) = &_config.region {
request
.properties_mut()
.insert(aws_types::region::SigningRegion::from(region.clone()));
}
let endpoint_params = aws_endpoint::Params::new(_config.region.clone());
request
.properties_mut()
.insert::<aws_smithy_http::endpoint::Result>(
_config.endpoint_resolver.resolve_endpoint(&endpoint_params),
);
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_provider(
&mut request.properties_mut(),
_config.credentials_provider.clone(),
);
let op =
aws_smithy_http::operation::Operation::new(request, crate::operation::GetObject::new())
.with_metadata(aws_smithy_http::operation::Metadata::new("GetObject", "s3"));
let op = op.with_retry_classifier(aws_http::retry::AwsResponseRetryClassifier::new());
Ok(op)
}
Trait Implementations§
source§impl ParseHttpResponse for GetObject
impl ParseHttpResponse for GetObject
§type Output = Result<GetObjectOutput, GetObjectError>
type Output = Result<GetObjectOutput, GetObjectError>
Output type of the HttpResponse. Read more