use serde::{Deserialize, Serialize}; /*
                                      * Service Control API
                                      *
                                      * Provides admission control and telemetry reporting for services integrated with Service Infrastructure.
                                      *
                                      * The version of the OpenAPI document: v2
                                      *
                                      * Generated by: https://openapi-generator.tech
                                      */

use crate::google_rest_apis::servicecontrol_v2::models;

/// V2ResourceEvent : Report v2 extension proto for passing the resource metadata associated with a resource create/update/delete/undelete event from ESF to Chemist. ResourceEvent proto should be serialized into the ReportRequest.operations.extensions.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct V2ResourceEvent {
    /// The ESF unique context id of the api request, from which this resource event originated. This field is only needed for CAIS integration via api annotation. See go/cais-lro-delete for more details.
    #[serde(rename = "contextId", skip_serializing_if = "Option::is_none")]
    pub context_id: Option<String>,
    /// The destinations field determines which backend services should handle the event. This should be specified as a comma-delimited string.
    #[serde(rename = "destinations", skip_serializing_if = "Option::is_none")]
    pub destinations: Option<String>,
    #[serde(rename = "parent", skip_serializing_if = "Option::is_none")]
    pub parent: Option<Box<models::Resource>>,
    /// The api path the resource event was created in. This should match the source of the `payload` field. For direct integrations with Chemist, this should generally be the RESPONSE. go/resource-event-pipeline-type
    #[serde(rename = "path", skip_serializing_if = "Option::is_none")]
    pub path: Option<Path>,
    /// The payload contains metadata associated with the resource event. A ResourceEventPayloadStatus is provided instead if the original payload cannot be returned due to a limitation (e.g. size limit).
    #[serde(rename = "payload", skip_serializing_if = "Option::is_none")]
    pub payload: Option<std::collections::HashMap<String, serde_json::Value>>,
    #[serde(rename = "resource", skip_serializing_if = "Option::is_none")]
    pub resource: Option<Box<models::Resource>>,
    /// The resource event type determines how the backend service should process the event.
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<Type>,
}

impl V2ResourceEvent {
    /// Report v2 extension proto for passing the resource metadata associated with a resource create/update/delete/undelete event from ESF to Chemist. ResourceEvent proto should be serialized into the ReportRequest.operations.extensions.
    pub fn new() -> V2ResourceEvent {
        V2ResourceEvent {
            context_id: None,
            destinations: None,
            parent: None,
            path: None,
            payload: None,
            resource: None,
            r#type: None,
        }
    }
}
/// The api path the resource event was created in. This should match the source of the `payload` field. For direct integrations with Chemist, this should generally be the RESPONSE. go/resource-event-pipeline-type
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Path {
    #[serde(rename = "API_PATH_UNSPECIFIED")]
    ApiPathUnspecified,
    #[serde(rename = "REQUEST")]
    Request,
    #[serde(rename = "RESPONSE")]
    Response,
}

impl Default for Path {
    fn default() -> Path {
        Self::ApiPathUnspecified
    }
}
/// The resource event type determines how the backend service should process the event.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "TYPE_UNSPECIFIED")]
    TypeUnspecified,
    #[serde(rename = "CREATE")]
    Create,
    #[serde(rename = "UPDATE")]
    Update,
    #[serde(rename = "DELETE")]
    Delete,
    #[serde(rename = "UNDELETE")]
    Undelete,
}

impl Default for Type {
    fn default() -> Type {
        Self::TypeUnspecified
    }
}
