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