use serde::de::{Error, MapAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct GCPAccount {
#[serde(rename = "auth_provider_x509_cert_url")]
pub auth_provider_x509_cert_url: Option<String>,
#[serde(rename = "auth_uri")]
pub auth_uri: Option<String>,
#[serde(rename = "automute")]
pub automute: Option<bool>,
#[serde(rename = "client_email")]
pub client_email: Option<String>,
#[serde(rename = "client_id")]
pub client_id: Option<String>,
#[serde(rename = "client_x509_cert_url")]
pub client_x509_cert_url: Option<String>,
#[deprecated]
#[serde(rename = "cloud_run_revision_filters")]
pub cloud_run_revision_filters: Option<Vec<String>>,
#[serde(rename = "errors")]
pub errors: Option<Vec<String>>,
#[deprecated]
#[serde(rename = "host_filters")]
pub host_filters: Option<String>,
#[serde(rename = "is_cspm_enabled")]
pub is_cspm_enabled: Option<bool>,
#[serde(rename = "is_resource_change_collection_enabled")]
pub is_resource_change_collection_enabled: Option<bool>,
#[serde(rename = "is_security_command_center_enabled")]
pub is_security_command_center_enabled: Option<bool>,
#[serde(rename = "monitored_resource_configs")]
pub monitored_resource_configs:
Option<Vec<crate::datadogV1::model::GCPMonitoredResourceConfig>>,
#[serde(rename = "private_key")]
pub private_key: Option<String>,
#[serde(rename = "private_key_id")]
pub private_key_id: Option<String>,
#[serde(rename = "project_id")]
pub project_id: Option<String>,
#[serde(rename = "resource_collection_enabled")]
pub resource_collection_enabled: Option<bool>,
#[serde(rename = "token_uri")]
pub token_uri: Option<String>,
#[serde(rename = "type")]
pub type_: Option<String>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}
impl GCPAccount {
pub fn new() -> GCPAccount {
#[allow(deprecated)]
GCPAccount {
auth_provider_x509_cert_url: None,
auth_uri: None,
automute: None,
client_email: None,
client_id: None,
client_x509_cert_url: None,
cloud_run_revision_filters: None,
errors: None,
host_filters: None,
is_cspm_enabled: None,
is_resource_change_collection_enabled: None,
is_security_command_center_enabled: None,
monitored_resource_configs: None,
private_key: None,
private_key_id: None,
project_id: None,
resource_collection_enabled: None,
token_uri: None,
type_: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}
#[allow(deprecated)]
pub fn auth_provider_x509_cert_url(mut self, value: String) -> Self {
self.auth_provider_x509_cert_url = Some(value);
self
}
#[allow(deprecated)]
pub fn auth_uri(mut self, value: String) -> Self {
self.auth_uri = Some(value);
self
}
#[allow(deprecated)]
pub fn automute(mut self, value: bool) -> Self {
self.automute = Some(value);
self
}
#[allow(deprecated)]
pub fn client_email(mut self, value: String) -> Self {
self.client_email = Some(value);
self
}
#[allow(deprecated)]
pub fn client_id(mut self, value: String) -> Self {
self.client_id = Some(value);
self
}
#[allow(deprecated)]
pub fn client_x509_cert_url(mut self, value: String) -> Self {
self.client_x509_cert_url = Some(value);
self
}
#[allow(deprecated)]
pub fn cloud_run_revision_filters(mut self, value: Vec<String>) -> Self {
self.cloud_run_revision_filters = Some(value);
self
}
#[allow(deprecated)]
pub fn errors(mut self, value: Vec<String>) -> Self {
self.errors = Some(value);
self
}
#[allow(deprecated)]
pub fn host_filters(mut self, value: String) -> Self {
self.host_filters = Some(value);
self
}
#[allow(deprecated)]
pub fn is_cspm_enabled(mut self, value: bool) -> Self {
self.is_cspm_enabled = Some(value);
self
}
#[allow(deprecated)]
pub fn is_resource_change_collection_enabled(mut self, value: bool) -> Self {
self.is_resource_change_collection_enabled = Some(value);
self
}
#[allow(deprecated)]
pub fn is_security_command_center_enabled(mut self, value: bool) -> Self {
self.is_security_command_center_enabled = Some(value);
self
}
#[allow(deprecated)]
pub fn monitored_resource_configs(
mut self,
value: Vec<crate::datadogV1::model::GCPMonitoredResourceConfig>,
) -> Self {
self.monitored_resource_configs = Some(value);
self
}
#[allow(deprecated)]
pub fn private_key(mut self, value: String) -> Self {
self.private_key = Some(value);
self
}
#[allow(deprecated)]
pub fn private_key_id(mut self, value: String) -> Self {
self.private_key_id = Some(value);
self
}
#[allow(deprecated)]
pub fn project_id(mut self, value: String) -> Self {
self.project_id = Some(value);
self
}
#[allow(deprecated)]
pub fn resource_collection_enabled(mut self, value: bool) -> Self {
self.resource_collection_enabled = Some(value);
self
}
#[allow(deprecated)]
pub fn token_uri(mut self, value: String) -> Self {
self.token_uri = Some(value);
self
}
#[allow(deprecated)]
pub fn type_(mut self, value: String) -> Self {
self.type_ = Some(value);
self
}
pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}
impl Default for GCPAccount {
fn default() -> Self {
Self::new()
}
}
impl<'de> Deserialize<'de> for GCPAccount {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct GCPAccountVisitor;
impl<'a> Visitor<'a> for GCPAccountVisitor {
type Value = GCPAccount;
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut auth_provider_x509_cert_url: Option<String> = None;
let mut auth_uri: Option<String> = None;
let mut automute: Option<bool> = None;
let mut client_email: Option<String> = None;
let mut client_id: Option<String> = None;
let mut client_x509_cert_url: Option<String> = None;
let mut cloud_run_revision_filters: Option<Vec<String>> = None;
let mut errors: Option<Vec<String>> = None;
let mut host_filters: Option<String> = None;
let mut is_cspm_enabled: Option<bool> = None;
let mut is_resource_change_collection_enabled: Option<bool> = None;
let mut is_security_command_center_enabled: Option<bool> = None;
let mut monitored_resource_configs: Option<
Vec<crate::datadogV1::model::GCPMonitoredResourceConfig>,
> = None;
let mut private_key: Option<String> = None;
let mut private_key_id: Option<String> = None;
let mut project_id: Option<String> = None;
let mut resource_collection_enabled: Option<bool> = None;
let mut token_uri: Option<String> = None;
let mut type_: Option<String> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
> = std::collections::BTreeMap::new();
let mut _unparsed = false;
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"auth_provider_x509_cert_url" => {
if v.is_null() {
continue;
}
auth_provider_x509_cert_url =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"auth_uri" => {
if v.is_null() {
continue;
}
auth_uri = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"automute" => {
if v.is_null() {
continue;
}
automute = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"client_email" => {
if v.is_null() {
continue;
}
client_email =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"client_id" => {
if v.is_null() {
continue;
}
client_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"client_x509_cert_url" => {
if v.is_null() {
continue;
}
client_x509_cert_url =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"cloud_run_revision_filters" => {
if v.is_null() {
continue;
}
cloud_run_revision_filters =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"errors" => {
if v.is_null() {
continue;
}
errors = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"host_filters" => {
if v.is_null() {
continue;
}
host_filters =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"is_cspm_enabled" => {
if v.is_null() {
continue;
}
is_cspm_enabled =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"is_resource_change_collection_enabled" => {
if v.is_null() {
continue;
}
is_resource_change_collection_enabled =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"is_security_command_center_enabled" => {
if v.is_null() {
continue;
}
is_security_command_center_enabled =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"monitored_resource_configs" => {
if v.is_null() {
continue;
}
monitored_resource_configs =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"private_key" => {
if v.is_null() {
continue;
}
private_key =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"private_key_id" => {
if v.is_null() {
continue;
}
private_key_id =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"project_id" => {
if v.is_null() {
continue;
}
project_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"resource_collection_enabled" => {
if v.is_null() {
continue;
}
resource_collection_enabled =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"token_uri" => {
if v.is_null() {
continue;
}
token_uri = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"type" => {
if v.is_null() {
continue;
}
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
#[allow(deprecated)]
let content = GCPAccount {
auth_provider_x509_cert_url,
auth_uri,
automute,
client_email,
client_id,
client_x509_cert_url,
cloud_run_revision_filters,
errors,
host_filters,
is_cspm_enabled,
is_resource_change_collection_enabled,
is_security_command_center_enabled,
monitored_resource_configs,
private_key,
private_key_id,
project_id,
resource_collection_enabled,
token_uri,
type_,
additional_properties,
_unparsed,
};
Ok(content)
}
}
deserializer.deserialize_any(GCPAccountVisitor)
}
}