1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetPackageVersionAsset;
6impl GetPackageVersionAsset {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::get_package_version_asset::GetPackageVersionAssetInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_package_version_asset::GetPackageVersionAssetOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_package_version_asset::GetPackageVersionAssetError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22 ::aws_smithy_runtime_api::client::interceptors::context::Error,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >| {
25 err.map_service_error(|err| {
26 err.downcast::<crate::operation::get_package_version_asset::GetPackageVersionAssetError>()
27 .expect("correct error type")
28 })
29 };
30 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31 .await
32 .map_err(map_err)?;
33 let output = context.finalize().map_err(map_err)?;
34 ::std::result::Result::Ok(
35 output
36 .downcast::<crate::operation::get_package_version_asset::GetPackageVersionAssetOutput>()
37 .expect("correct output type"),
38 )
39 }
40
41 pub(crate) async fn orchestrate_with_stop_point(
42 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43 input: crate::operation::get_package_version_asset::GetPackageVersionAssetInput,
44 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45 ) -> ::std::result::Result<
46 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47 ::aws_smithy_runtime_api::client::result::SdkError<
48 ::aws_smithy_runtime_api::client::interceptors::context::Error,
49 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50 >,
51 > {
52 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53 use ::tracing::Instrument;
54 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
55 "codeartifact",
56 "GetPackageVersionAsset",
57 input,
58 runtime_plugins,
59 stop_point,
60 )
61 .instrument(::tracing::debug_span!(
64 "codeartifact.GetPackageVersionAsset",
65 "rpc.service" = "codeartifact",
66 "rpc.method" = "GetPackageVersionAsset",
67 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
68 "rpc.system" = "aws-api",
69 ))
70 .await
71 }
72
73 pub(crate) fn operation_runtime_plugins(
74 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
75 client_config: &crate::config::Config,
76 config_override: ::std::option::Option<crate::config::Builder>,
77 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
78 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
79 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
80 ::aws_runtime::auth::sigv4::SCHEME_ID,
81 ]));
82 if let ::std::option::Option::Some(config_override) = config_override {
83 for plugin in config_override.runtime_plugins.iter().cloned() {
84 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
85 }
86 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
87 config_override,
88 client_config.config.clone(),
89 &client_config.runtime_components,
90 ));
91 }
92 runtime_plugins
93 }
94}
95impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetPackageVersionAsset {
96 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
97 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetPackageVersionAsset");
98
99 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
100 GetPackageVersionAssetRequestSerializer,
101 ));
102 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
103 GetPackageVersionAssetResponseDeserializer,
104 ));
105
106 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
107 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
108 ));
109
110 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
111 "GetPackageVersionAsset",
112 "codeartifact",
113 ));
114 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
115 signing_options.double_uri_encode = true;
116 signing_options.content_sha256_header = false;
117 signing_options.normalize_uri_path = true;
118 signing_options.payload_override = None;
119
120 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
121 signing_options,
122 ..::std::default::Default::default()
123 });
124
125 ::std::option::Option::Some(cfg.freeze())
126 }
127
128 fn runtime_components(
129 &self,
130 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
131 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
132 #[allow(unused_mut)]
133 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetPackageVersionAsset")
134 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
135 .with_interceptor(GetPackageVersionAssetEndpointParamsInterceptor)
136 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
137 crate::operation::get_package_version_asset::GetPackageVersionAssetError,
138 >::new())
139 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
140 crate::operation::get_package_version_asset::GetPackageVersionAssetError,
141 >::new())
142 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
143 crate::operation::get_package_version_asset::GetPackageVersionAssetError,
144 >::new());
145
146 ::std::borrow::Cow::Owned(rcb)
147 }
148}
149
150#[derive(Debug)]
151struct GetPackageVersionAssetResponseDeserializer;
152impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetPackageVersionAssetResponseDeserializer {
153 fn deserialize_streaming(
154 &self,
155 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
156 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
157 #[allow(unused_mut)]
158 let mut force_error = false;
159 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
160
161 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
163 return ::std::option::Option::None;
164 }
165 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
166 crate::protocol_serde::shape_get_package_version_asset::de_get_package_version_asset_http_response(response),
167 ))
168 }
169
170 fn deserialize_nonstreaming(
171 &self,
172 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
173 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
174 let body = response.body().bytes().expect("body loaded");
176 crate::protocol_serde::type_erase_result(
177 crate::protocol_serde::shape_get_package_version_asset::de_get_package_version_asset_http_error(
178 response.status().as_u16(),
179 response.headers(),
180 body,
181 ),
182 )
183 }
184}
185#[derive(Debug)]
186struct GetPackageVersionAssetRequestSerializer;
187impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetPackageVersionAssetRequestSerializer {
188 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
189 fn serialize_input(
190 &self,
191 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
192 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
193 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
194 let input = input
195 .downcast::<crate::operation::get_package_version_asset::GetPackageVersionAssetInput>()
196 .expect("correct type");
197 let _header_serialization_settings = _cfg
198 .load::<crate::serialization_settings::HeaderSerializationSettings>()
199 .cloned()
200 .unwrap_or_default();
201 let mut request_builder = {
202 fn uri_base(
203 _input: &crate::operation::get_package_version_asset::GetPackageVersionAssetInput,
204 output: &mut ::std::string::String,
205 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
206 use ::std::fmt::Write as _;
207 ::std::write!(output, "/v1/package/version/asset").expect("formatting should succeed");
208 ::std::result::Result::Ok(())
209 }
210 fn uri_query(
211 _input: &crate::operation::get_package_version_asset::GetPackageVersionAssetInput,
212 mut output: &mut ::std::string::String,
213 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
214 let mut query = ::aws_smithy_http::query::Writer::new(output);
215 let inner_1 = &_input.domain;
216 let inner_1 = inner_1
217 .as_ref()
218 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("domain", "cannot be empty or unset"))?;
219 if inner_1.is_empty() {
220 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
221 "domain",
222 "cannot be empty or unset",
223 ));
224 }
225 query.push_kv("domain", &::aws_smithy_http::query::fmt_string(inner_1));
226 if let ::std::option::Option::Some(inner_2) = &_input.domain_owner {
227 {
228 query.push_kv("domain-owner", &::aws_smithy_http::query::fmt_string(inner_2));
229 }
230 }
231 let inner_3 = &_input.repository;
232 let inner_3 = inner_3
233 .as_ref()
234 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("repository", "cannot be empty or unset"))?;
235 if inner_3.is_empty() {
236 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
237 "repository",
238 "cannot be empty or unset",
239 ));
240 }
241 query.push_kv("repository", &::aws_smithy_http::query::fmt_string(inner_3));
242 let inner_4 = &_input.format;
243 let inner_4 = inner_4
244 .as_ref()
245 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("format", "cannot be empty or unset"))?;
246 query.push_kv("format", &::aws_smithy_http::query::fmt_string(inner_4));
247 if let ::std::option::Option::Some(inner_5) = &_input.namespace {
248 {
249 query.push_kv("namespace", &::aws_smithy_http::query::fmt_string(inner_5));
250 }
251 }
252 let inner_6 = &_input.package;
253 let inner_6 = inner_6
254 .as_ref()
255 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("package", "cannot be empty or unset"))?;
256 if inner_6.is_empty() {
257 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
258 "package",
259 "cannot be empty or unset",
260 ));
261 }
262 query.push_kv("package", &::aws_smithy_http::query::fmt_string(inner_6));
263 let inner_7 = &_input.package_version;
264 let inner_7 = inner_7
265 .as_ref()
266 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("package_version", "cannot be empty or unset"))?;
267 if inner_7.is_empty() {
268 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
269 "package_version",
270 "cannot be empty or unset",
271 ));
272 }
273 query.push_kv("version", &::aws_smithy_http::query::fmt_string(inner_7));
274 let inner_8 = &_input.asset;
275 let inner_8 = inner_8
276 .as_ref()
277 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("asset", "cannot be empty or unset"))?;
278 if inner_8.is_empty() {
279 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
280 "asset",
281 "cannot be empty or unset",
282 ));
283 }
284 query.push_kv("asset", &::aws_smithy_http::query::fmt_string(inner_8));
285 if let ::std::option::Option::Some(inner_9) = &_input.package_version_revision {
286 {
287 query.push_kv("revision", &::aws_smithy_http::query::fmt_string(inner_9));
288 }
289 }
290 ::std::result::Result::Ok(())
291 }
292 #[allow(clippy::unnecessary_wraps)]
293 fn update_http_builder(
294 input: &crate::operation::get_package_version_asset::GetPackageVersionAssetInput,
295 builder: ::http::request::Builder,
296 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
297 let mut uri = ::std::string::String::new();
298 uri_base(input, &mut uri)?;
299 uri_query(input, &mut uri)?;
300 ::std::result::Result::Ok(builder.method("GET").uri(uri))
301 }
302 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
303 builder
304 };
305 let body = ::aws_smithy_types::body::SdkBody::from("");
306
307 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
308 }
309}
310#[derive(Debug)]
311struct GetPackageVersionAssetEndpointParamsInterceptor;
312
313impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetPackageVersionAssetEndpointParamsInterceptor {
314 fn name(&self) -> &'static str {
315 "GetPackageVersionAssetEndpointParamsInterceptor"
316 }
317
318 fn read_before_execution(
319 &self,
320 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
321 '_,
322 ::aws_smithy_runtime_api::client::interceptors::context::Input,
323 ::aws_smithy_runtime_api::client::interceptors::context::Output,
324 ::aws_smithy_runtime_api::client::interceptors::context::Error,
325 >,
326 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
327 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
328 let _input = context
329 .input()
330 .downcast_ref::<GetPackageVersionAssetInput>()
331 .ok_or("failed to downcast to GetPackageVersionAssetInput")?;
332
333 let params = crate::config::endpoint::Params::builder()
334 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
335 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
336 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
337 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
338 .build()
339 .map_err(|err| {
340 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
341 })?;
342 cfg.interceptor_state()
343 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
344 ::std::result::Result::Ok(())
345 }
346}
347
348#[non_exhaustive]
353#[derive(::std::fmt::Debug)]
354pub enum GetPackageVersionAssetError {
355 AccessDeniedException(crate::types::error::AccessDeniedException),
357 ConflictException(crate::types::error::ConflictException),
359 InternalServerException(crate::types::error::InternalServerException),
361 ResourceNotFoundException(crate::types::error::ResourceNotFoundException),
363 ThrottlingException(crate::types::error::ThrottlingException),
365 ValidationException(crate::types::error::ValidationException),
367 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
369 variable wildcard pattern and check `.code()`:
370 \
371 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
372 \
373 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetPackageVersionAssetError) for what information is available for the error.")]
374 Unhandled(crate::error::sealed_unhandled::Unhandled),
375}
376impl GetPackageVersionAssetError {
377 pub fn unhandled(
379 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
380 ) -> Self {
381 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
382 source: err.into(),
383 meta: ::std::default::Default::default(),
384 })
385 }
386
387 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
389 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
390 source: err.clone().into(),
391 meta: err,
392 })
393 }
394 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
399 match self {
400 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
401 Self::ConflictException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
402 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
403 Self::ResourceNotFoundException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
404 Self::ThrottlingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
405 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
406 Self::Unhandled(e) => &e.meta,
407 }
408 }
409 pub fn is_access_denied_exception(&self) -> bool {
411 matches!(self, Self::AccessDeniedException(_))
412 }
413 pub fn is_conflict_exception(&self) -> bool {
415 matches!(self, Self::ConflictException(_))
416 }
417 pub fn is_internal_server_exception(&self) -> bool {
419 matches!(self, Self::InternalServerException(_))
420 }
421 pub fn is_resource_not_found_exception(&self) -> bool {
423 matches!(self, Self::ResourceNotFoundException(_))
424 }
425 pub fn is_throttling_exception(&self) -> bool {
427 matches!(self, Self::ThrottlingException(_))
428 }
429 pub fn is_validation_exception(&self) -> bool {
431 matches!(self, Self::ValidationException(_))
432 }
433}
434impl ::std::error::Error for GetPackageVersionAssetError {
435 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
436 match self {
437 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
438 Self::ConflictException(_inner) => ::std::option::Option::Some(_inner),
439 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
440 Self::ResourceNotFoundException(_inner) => ::std::option::Option::Some(_inner),
441 Self::ThrottlingException(_inner) => ::std::option::Option::Some(_inner),
442 Self::ValidationException(_inner) => ::std::option::Option::Some(_inner),
443 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
444 }
445 }
446}
447impl ::std::fmt::Display for GetPackageVersionAssetError {
448 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
449 match self {
450 Self::AccessDeniedException(_inner) => _inner.fmt(f),
451 Self::ConflictException(_inner) => _inner.fmt(f),
452 Self::InternalServerException(_inner) => _inner.fmt(f),
453 Self::ResourceNotFoundException(_inner) => _inner.fmt(f),
454 Self::ThrottlingException(_inner) => _inner.fmt(f),
455 Self::ValidationException(_inner) => _inner.fmt(f),
456 Self::Unhandled(_inner) => {
457 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
458 write!(f, "unhandled error ({code})")
459 } else {
460 f.write_str("unhandled error")
461 }
462 }
463 }
464 }
465}
466impl ::aws_smithy_types::retry::ProvideErrorKind for GetPackageVersionAssetError {
467 fn code(&self) -> ::std::option::Option<&str> {
468 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
469 }
470 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
471 ::std::option::Option::None
472 }
473}
474impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetPackageVersionAssetError {
475 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
476 match self {
477 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
478 Self::ConflictException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
479 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
480 Self::ResourceNotFoundException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
481 Self::ThrottlingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
482 Self::ValidationException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
483 Self::Unhandled(_inner) => &_inner.meta,
484 }
485 }
486}
487impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetPackageVersionAssetError {
488 fn create_unhandled_error(
489 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
490 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
491 ) -> Self {
492 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
493 source,
494 meta: meta.unwrap_or_default(),
495 })
496 }
497}
498impl ::aws_types::request_id::RequestId for crate::operation::get_package_version_asset::GetPackageVersionAssetError {
499 fn request_id(&self) -> Option<&str> {
500 self.meta().request_id()
501 }
502}
503
504pub use crate::operation::get_package_version_asset::_get_package_version_asset_output::GetPackageVersionAssetOutput;
505
506pub use crate::operation::get_package_version_asset::_get_package_version_asset_input::GetPackageVersionAssetInput;
507
508mod _get_package_version_asset_input;
509
510mod _get_package_version_asset_output;
511
512pub mod builders;