aws-sdk-devopsagent 1.3.0

AWS SDK for AWS DevOps Agent Service
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_service_configuration(
    object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::ServiceConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    match input {
        crate::types::ServiceConfiguration::SourceAws(inner) => {
            #[allow(unused_mut)]
            let mut object_1 = object_2.key("sourceAws").start_object();
            crate::protocol_serde::shape_source_aws_configuration::ser_source_aws_configuration(&mut object_1, inner)?;
            object_1.finish();
        }
        crate::types::ServiceConfiguration::Aws(inner) => {
            #[allow(unused_mut)]
            let mut object_2 = object_2.key("aws").start_object();
            crate::protocol_serde::shape_aws_configuration::ser_aws_configuration(&mut object_2, inner)?;
            object_2.finish();
        }
        crate::types::ServiceConfiguration::Github(inner) => {
            #[allow(unused_mut)]
            let mut object_3 = object_2.key("github").start_object();
            crate::protocol_serde::shape_git_hub_configuration::ser_git_hub_configuration(&mut object_3, inner)?;
            object_3.finish();
        }
        crate::types::ServiceConfiguration::Slack(inner) => {
            #[allow(unused_mut)]
            let mut object_4 = object_2.key("slack").start_object();
            crate::protocol_serde::shape_slack_configuration::ser_slack_configuration(&mut object_4, inner)?;
            object_4.finish();
        }
        crate::types::ServiceConfiguration::Dynatrace(inner) => {
            #[allow(unused_mut)]
            let mut object_5 = object_2.key("dynatrace").start_object();
            crate::protocol_serde::shape_dynatrace_configuration::ser_dynatrace_configuration(&mut object_5, inner)?;
            object_5.finish();
        }
        crate::types::ServiceConfiguration::Servicenow(inner) => {
            #[allow(unused_mut)]
            let mut object_6 = object_2.key("servicenow").start_object();
            crate::protocol_serde::shape_service_now_configuration::ser_service_now_configuration(&mut object_6, inner)?;
            object_6.finish();
        }
        crate::types::ServiceConfiguration::Mcpservernewrelic(inner) => {
            #[allow(unused_mut)]
            let mut object_7 = object_2.key("mcpservernewrelic").start_object();
            crate::protocol_serde::shape_mcp_server_new_relic_configuration::ser_mcp_server_new_relic_configuration(&mut object_7, inner)?;
            object_7.finish();
        }
        crate::types::ServiceConfiguration::Mcpserverdatadog(inner) => {
            #[allow(unused_mut)]
            let mut object_8 = object_2.key("mcpserverdatadog").start_object();
            crate::protocol_serde::shape_mcp_server_datadog_configuration::ser_mcp_server_datadog_configuration(&mut object_8, inner)?;
            object_8.finish();
        }
        crate::types::ServiceConfiguration::Mcpserver(inner) => {
            #[allow(unused_mut)]
            let mut object_9 = object_2.key("mcpserver").start_object();
            crate::protocol_serde::shape_mcp_server_configuration::ser_mcp_server_configuration(&mut object_9, inner)?;
            object_9.finish();
        }
        crate::types::ServiceConfiguration::Gitlab(inner) => {
            #[allow(unused_mut)]
            let mut object_10 = object_2.key("gitlab").start_object();
            crate::protocol_serde::shape_git_lab_configuration::ser_git_lab_configuration(&mut object_10, inner)?;
            object_10.finish();
        }
        crate::types::ServiceConfiguration::Mcpserversplunk(inner) => {
            #[allow(unused_mut)]
            let mut object_11 = object_2.key("mcpserversplunk").start_object();
            crate::protocol_serde::shape_mcp_server_splunk_configuration::ser_mcp_server_splunk_configuration(&mut object_11, inner)?;
            object_11.finish();
        }
        crate::types::ServiceConfiguration::EventChannel(inner) => {
            #[allow(unused_mut)]
            let mut object_12 = object_2.key("eventChannel").start_object();
            crate::protocol_serde::shape_event_channel_configuration::ser_event_channel_configuration(&mut object_12, inner)?;
            object_12.finish();
        }
        crate::types::ServiceConfiguration::Azure(inner) => {
            #[allow(unused_mut)]
            let mut object_13 = object_2.key("azure").start_object();
            crate::protocol_serde::shape_azure_configuration::ser_azure_configuration(&mut object_13, inner)?;
            object_13.finish();
        }
        crate::types::ServiceConfiguration::Azuredevops(inner) => {
            #[allow(unused_mut)]
            let mut object_14 = object_2.key("azuredevops").start_object();
            crate::protocol_serde::shape_azure_dev_ops_configuration::ser_azure_dev_ops_configuration(&mut object_14, inner)?;
            object_14.finish();
        }
        crate::types::ServiceConfiguration::Mcpservergrafana(inner) => {
            #[allow(unused_mut)]
            let mut object_15 = object_2.key("mcpservergrafana").start_object();
            crate::protocol_serde::shape_mcp_server_grafana_configuration::ser_mcp_server_grafana_configuration(&mut object_15, inner)?;
            object_15.finish();
        }
        crate::types::ServiceConfiguration::Pagerduty(inner) => {
            #[allow(unused_mut)]
            let mut object_16 = object_2.key("pagerduty").start_object();
            crate::protocol_serde::shape_pager_duty_configuration::ser_pager_duty_configuration(&mut object_16, inner)?;
            object_16.finish();
        }
        crate::types::ServiceConfiguration::Unknown => {
            return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "ServiceConfiguration",
            ))
        }
    }
    Ok(())
}

pub(crate) fn de_service_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ServiceConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    let mut variant = None;
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
            match tokens.next().transpose()? {
                Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                    if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
                        tokens.peek()
                    {
                        let _ = tokens.next().expect("peek returned a token")?;
                        continue;
                    }
                    let key = key.to_unescaped()?;
                    if key == "__type" {
                        ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                        continue;
                    }
                    if variant.is_some() {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                            "encountered mixed variants in union",
                        ));
                    }
                    variant = match key.as_ref() {
                        "sourceAws" => Some(crate::types::ServiceConfiguration::SourceAws(
                            crate::protocol_serde::shape_source_aws_configuration::de_source_aws_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'sourceAws' cannot be null")
                            })?,
                        )),
                        "aws" => Some(crate::types::ServiceConfiguration::Aws(
                            crate::protocol_serde::shape_aws_configuration::de_aws_configuration(tokens, _value)?
                                .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'aws' cannot be null"))?,
                        )),
                        "github" => Some(crate::types::ServiceConfiguration::Github(
                            crate::protocol_serde::shape_git_hub_configuration::de_git_hub_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'github' cannot be null")
                            })?,
                        )),
                        "slack" => Some(crate::types::ServiceConfiguration::Slack(
                            crate::protocol_serde::shape_slack_configuration::de_slack_configuration(tokens, _value)?
                                .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'slack' cannot be null"))?,
                        )),
                        "dynatrace" => Some(crate::types::ServiceConfiguration::Dynatrace(
                            crate::protocol_serde::shape_dynatrace_configuration::de_dynatrace_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'dynatrace' cannot be null")
                            })?,
                        )),
                        "servicenow" => Some(crate::types::ServiceConfiguration::Servicenow(
                            crate::protocol_serde::shape_service_now_configuration::de_service_now_configuration(tokens, _value)?.ok_or_else(
                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'servicenow' cannot be null"),
                            )?,
                        )),
                        "mcpservernewrelic" => Some(crate::types::ServiceConfiguration::Mcpservernewrelic(
                            crate::protocol_serde::shape_mcp_server_new_relic_configuration::de_mcp_server_new_relic_configuration(tokens, _value)?
                                .ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mcpservernewrelic' cannot be null")
                            })?,
                        )),
                        "mcpserverdatadog" => Some(crate::types::ServiceConfiguration::Mcpserverdatadog(
                            crate::protocol_serde::shape_mcp_server_datadog_configuration::de_mcp_server_datadog_configuration(tokens, _value)?
                                .ok_or_else(|| {
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mcpserverdatadog' cannot be null")
                                })?,
                        )),
                        "mcpserver" => Some(crate::types::ServiceConfiguration::Mcpserver(
                            crate::protocol_serde::shape_mcp_server_configuration::de_mcp_server_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mcpserver' cannot be null")
                            })?,
                        )),
                        "gitlab" => Some(crate::types::ServiceConfiguration::Gitlab(
                            crate::protocol_serde::shape_git_lab_configuration::de_git_lab_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'gitlab' cannot be null")
                            })?,
                        )),
                        "mcpserversplunk" => Some(crate::types::ServiceConfiguration::Mcpserversplunk(
                            crate::protocol_serde::shape_mcp_server_splunk_configuration::de_mcp_server_splunk_configuration(tokens, _value)?
                                .ok_or_else(|| {
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mcpserversplunk' cannot be null")
                                })?,
                        )),
                        "eventChannel" => Some(crate::types::ServiceConfiguration::EventChannel(
                            crate::protocol_serde::shape_event_channel_configuration::de_event_channel_configuration(tokens, _value)?.ok_or_else(
                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'eventChannel' cannot be null"),
                            )?,
                        )),
                        "azure" => Some(crate::types::ServiceConfiguration::Azure(
                            crate::protocol_serde::shape_azure_configuration::de_azure_configuration(tokens, _value)?
                                .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'azure' cannot be null"))?,
                        )),
                        "azuredevops" => Some(crate::types::ServiceConfiguration::Azuredevops(
                            crate::protocol_serde::shape_azure_dev_ops_configuration::de_azure_dev_ops_configuration(tokens, _value)?.ok_or_else(
                                || ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'azuredevops' cannot be null"),
                            )?,
                        )),
                        "mcpservergrafana" => Some(crate::types::ServiceConfiguration::Mcpservergrafana(
                            crate::protocol_serde::shape_mcp_server_grafana_configuration::de_mcp_server_grafana_configuration(tokens, _value)?
                                .ok_or_else(|| {
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mcpservergrafana' cannot be null")
                                })?,
                        )),
                        "pagerduty" => Some(crate::types::ServiceConfiguration::Pagerduty(
                            crate::protocol_serde::shape_pager_duty_configuration::de_pager_duty_configuration(tokens, _value)?.ok_or_else(|| {
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'pagerduty' cannot be null")
                            })?,
                        )),
                        _ => {
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                            Some(crate::types::ServiceConfiguration::Unknown)
                        }
                    };
                }
                other => {
                    return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                        "expected object key or end object, found: {other:?}"
                    )))
                }
            }
        },
        _ => {
            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ))
        }
    }
    if variant.is_none() {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "Union did not contain a valid variant.",
        ));
    }
    Ok(variant)
}