#[allow(clippy::unnecessary_wraps)]
pub fn de_enable_organizations_root_sessions_http_error(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsOutput,
crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError,
> {
#[allow(unused_mut)]
let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
.map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
let generic = generic_builder.build();
let error_code = match generic.code() {
Some(code) => code,
None => return Err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled(generic)),
};
let _error_message = generic.message().map(|msg| msg.to_owned());
Err(match error_code {
"AccountNotManagementOrDelegatedAdministratorException" => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::AccountNotManagementOrDelegatedAdministratorException({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::AccountNotManagementOrDelegatedAdministratorExceptionBuilder::default();
output = crate::protocol_serde::shape_account_not_management_or_delegated_administrator_exception::de_account_not_management_or_delegated_administrator_exception_xml_err(_response_body, output).map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
let output = output.meta(generic);
output.build()
}
;
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"CallerIsNotManagementAccountException" => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::CallerIsNotManagementAccountException({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::CallerIsNotManagementAccountExceptionBuilder::default();
output = crate::protocol_serde::shape_caller_is_not_management_account_exception::de_caller_is_not_management_account_exception_xml_err(_response_body, output).map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
let output = output.meta(generic);
output.build()
}
;
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"OrganizationNotFoundException" => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::OrganizationNotFoundException({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::OrganizationNotFoundExceptionBuilder::default();
output = crate::protocol_serde::shape_organization_not_found_exception::de_organization_not_found_exception_xml_err(_response_body, output).map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
let output = output.meta(generic);
output.build()
}
;
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"OrganizationNotInAllFeaturesModeException" => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::OrganizationNotInAllFeaturesModeException({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::OrganizationNotInAllFeaturesModeExceptionBuilder::default();
output = crate::protocol_serde::shape_organization_not_in_all_features_mode_exception::de_organization_not_in_all_features_mode_exception_xml_err(_response_body, output).map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
let output = output.meta(generic);
output.build()
}
;
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
"ServiceAccessNotEnabledException" => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::ServiceAccessNotEnabledException({
#[allow(unused_mut)]
let mut tmp =
{
#[allow(unused_mut)]
let mut output = crate::types::error::builders::ServiceAccessNotEnabledExceptionBuilder::default();
output = crate::protocol_serde::shape_service_access_not_enabled_exception::de_service_access_not_enabled_exception_xml_err(_response_body, output).map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
let output = output.meta(generic);
output.build()
}
;
if tmp.message.is_none() {
tmp.message = _error_message;
}
tmp
}),
_ => crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::generic(generic)
})
}
#[allow(clippy::unnecessary_wraps)]
pub fn de_enable_organizations_root_sessions_http_response(
_response_status: u16,
_response_headers: &::aws_smithy_runtime_api::http::Headers,
_response_body: &[u8],
) -> std::result::Result<
crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsOutput,
crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError,
> {
Ok({
#[allow(unused_mut)]
let mut output = crate::operation::enable_organizations_root_sessions::builders::EnableOrganizationsRootSessionsOutputBuilder::default();
output = crate::protocol_serde::shape_enable_organizations_root_sessions::de_enable_organizations_root_sessions(_response_body, output)
.map_err(crate::operation::enable_organizations_root_sessions::EnableOrganizationsRootSessionsError::unhandled)?;
output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
output.build()
})
}
#[allow(unused_mut)]
pub fn de_enable_organizations_root_sessions(
inp: &[u8],
mut builder: crate::operation::enable_organizations_root_sessions::builders::EnableOrganizationsRootSessionsOutputBuilder,
) -> std::result::Result<
crate::operation::enable_organizations_root_sessions::builders::EnableOrganizationsRootSessionsOutputBuilder,
::aws_smithy_xml::decode::XmlDecodeError,
> {
let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
#[allow(unused_mut)]
let mut decoder = doc.root_element()?;
#[allow(unused_variables)]
let start_el = decoder.start_el();
if !(start_el.matches("EnableOrganizationsRootSessionsResponse")) {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
"invalid root, expected EnableOrganizationsRootSessionsResponse got {start_el:?}"
)));
}
if let Some(mut result_tag) = decoder.next_tag() {
let start_el = result_tag.start_el();
if !(start_el.matches("EnableOrganizationsRootSessionsResult")) {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
"invalid result, expected EnableOrganizationsRootSessionsResult got {start_el:?}"
)));
}
while let Some(mut tag) = result_tag.next_tag() {
match tag.start_el() {
s if s.matches("OrganizationId") => {
let var_1 =
Some(
Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
.into()
)
?
)
;
builder = builder.set_organization_id(var_1);
}
,
s if s.matches("EnabledFeatures") => {
let var_2 =
Some(
crate::protocol_serde::shape_features_list_type::de_features_list_type(&mut tag)
?
)
;
builder = builder.set_enabled_features(var_2);
}
,
_ => {}
}
}
} else {
return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(
"expected EnableOrganizationsRootSessionsResult tag",
));
};
Ok(builder)
}