// this file is @generated
use clap::{Args, Subcommand};
use svix::api::Svix;
#[allow(unused_imports)]
use svix::models::*;

use super::endpoint_transformation::EndpointTransformationArgs;
#[derive(Args, Clone)]
pub struct EndpointListOptions {
    /// Limit the number of returned items
    #[arg(long)]
    pub limit: Option<u64>,

    /// The iterator returned from a prior invocation
    #[arg(long)]
    pub iterator: Option<String>,

    /// The sorting order of the returned items
    #[arg(long)]
    pub order: Option<Ordering>,
}

impl From<EndpointListOptions> for svix::api::EndpointListOptions {
    fn from(value: EndpointListOptions) -> Self {
        let EndpointListOptions {
            limit,
            iterator,
            order,
        } = value;
        Self {
            limit,
            iterator,
            order,
        }
    }
}

#[derive(Args, Clone)]
pub struct EndpointCreateOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointCreateOptions> for svix::api::EndpointCreateOptions {
    fn from(value: EndpointCreateOptions) -> Self {
        let EndpointCreateOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args, Clone)]
pub struct EndpointRotateSecretOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointRotateSecretOptions> for svix::api::EndpointRotateSecretOptions {
    fn from(value: EndpointRotateSecretOptions) -> Self {
        let EndpointRotateSecretOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args, Clone)]
pub struct EndpointReplayMissingOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointReplayMissingOptions> for svix::api::EndpointReplayMissingOptions {
    fn from(value: EndpointReplayMissingOptions) -> Self {
        let EndpointReplayMissingOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args, Clone)]
pub struct EndpointBulkReplayOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointBulkReplayOptions> for svix::api::EndpointBulkReplayOptions {
    fn from(value: EndpointBulkReplayOptions) -> Self {
        let EndpointBulkReplayOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args, Clone)]
pub struct EndpointGetStatsOptions {
    /// Filter the range to data starting from this date.
    #[arg(long)]
    pub since: Option<chrono::DateTime<chrono::Utc>>,
    /// Filter the range to data ending by this date.
    #[arg(long)]
    pub until: Option<chrono::DateTime<chrono::Utc>>,
}

impl From<EndpointGetStatsOptions> for svix::api::EndpointGetStatsOptions {
    fn from(value: EndpointGetStatsOptions) -> Self {
        let EndpointGetStatsOptions { since, until } = value;
        Self { since, until }
    }
}

#[derive(Args, Clone)]
pub struct EndpointRecoverOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointRecoverOptions> for svix::api::EndpointRecoverOptions {
    fn from(value: EndpointRecoverOptions) -> Self {
        let EndpointRecoverOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args, Clone)]
pub struct EndpointSendExampleOptions {
    #[arg(long)]
    pub idempotency_key: Option<String>,
}

impl From<EndpointSendExampleOptions> for svix::api::EndpointSendExampleOptions {
    fn from(value: EndpointSendExampleOptions) -> Self {
        let EndpointSendExampleOptions { idempotency_key } = value;
        Self { idempotency_key }
    }
}

#[derive(Args)]
#[command(args_conflicts_with_subcommands = true, flatten_help = true)]
pub struct EndpointArgs {
    #[command(subcommand)]
    pub command: EndpointCommands,
}

#[allow(clippy::large_enum_variant)]
#[derive(Subcommand)]
pub enum EndpointCommands {
    Transformation(EndpointTransformationArgs),
    /// List the application's endpoints.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint list app_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example response:
{
  \"data\": [{
    \"id\": \"ep_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
    \"metadata\": {\"key\": \"...\"},
    \"url\": \"https://example.com/webhook/\",
    \"description\": \"...\",
    \"throttleRate\": 123,
    \"uid\": \"unique-identifier\",
    \"disabled\": false,
    \"eventTypes\": [\"user.signup\",\"user.deleted\"],
    \"channels\": [\"project_123\",\"group_2\"],
    \"createdAt\": \"2030-01-01T00:00:00Z\",
    \"updatedAt\": \"2030-01-01T00:00:00Z\"
  }],
  \"iterator\": \"iterator\",
  \"prevIterator\": \"-iterator\",
  \"done\": true
}\n")]
    List {
        app_id: String,
        #[clap(flatten)]
        options: EndpointListOptions,
    },
    /// Create a new endpoint for the application.
    ///
    /// When `secret` is `null` the secret is automatically generated (recommended).
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint create app_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"An example endpoint name\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"secret\": \"whsec_C2FVsBQIhrscChlQIMV+b5sSYspob7oD\",
  \"metadata\": {\"key\": \"...\"},
  \"headers\": {
    \"X-Example\": \"123\",
    \"X-Foobar\": \"Bar\"
  }
}\n\nExample response:
{
  \"id\": \"ep_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"metadata\": {\"key\": \"...\"},
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"...\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"createdAt\": \"2030-01-01T00:00:00Z\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    Create {
        app_id: String,
        endpoint_in: crate::json::JsonOf<EndpointIn>,
        #[clap(flatten)]
        options: EndpointCreateOptions,
    },
    /// Get an endpoint.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint get app_abc000000000000000000000000 ep_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example response:
{
  \"id\": \"ep_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"metadata\": {\"key\": \"...\"},
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"...\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"createdAt\": \"2030-01-01T00:00:00Z\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    Get {
        app_id: String,
        id: String,
    },
    /// Create or update an endpoint.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint upsert app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"An example endpoint name\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"metadata\": {\"key\": \"...\"}
}\n\nExample response:
{
  \"id\": \"ep_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"metadata\": {\"key\": \"...\"},
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"...\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"createdAt\": \"2030-01-01T00:00:00Z\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    Upsert {
        app_id: String,
        id: String,
        endpoint_upsert_in: crate::json::JsonOf<EndpointUpsertIn>,
    },
    /// Delete an endpoint.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint delete app_abc000000000000000000000000 ep_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    Delete {
        app_id: String,
        id: String,
    },
    /// Partially update an endpoint.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint patch app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"description\": \"...\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"url\": \"...\",
  \"disabled\": true,
  \"eventTypes\": [\"...\"],
  \"channels\": [\"...\"],
  \"metadata\": {\"key\": \"...\"}
}\n\nExample response:
{
  \"id\": \"ep_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"metadata\": {\"key\": \"...\"},
  \"url\": \"https://example.com/webhook/\",
  \"description\": \"...\",
  \"throttleRate\": 123,
  \"uid\": \"unique-identifier\",
  \"disabled\": false,
  \"eventTypes\": [\"user.signup\",\"user.deleted\"],
  \"channels\": [\"project_123\",\"group_2\"],
  \"createdAt\": \"2030-01-01T00:00:00Z\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    Patch {
        app_id: String,
        id: String,
        endpoint_patch: Option<crate::json::JsonOf<EndpointPatch>>,
    },
    /// Get the endpoint's signing secret.
    ///
    /// This is used to verify the authenticity of the webhook.
    /// For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint get-secret app_abc000000000000000000000000 ep_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example response:
{
  \"key\": \"whsec_C2FVsBQIhrscChlQIMV+b5sSYspob7oD\"
}\n")]
    GetSecret {
        app_id: String,
        id: String,
    },
    /// Rotates the endpoint's signing secret.
    ///
    /// The previous secret will remain valid for the specified grace period (default 24 hours).
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint rotate-secret app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"key\": \"whsec_C2FVsBQIhrscChlQIMV+b5sSYspob7oD\",
  \"gracePeriodSeconds\": 123
}\n")]
    RotateSecret {
        app_id: String,
        id: String,
        endpoint_secret_rotate_in: Option<crate::json::JsonOf<EndpointSecretRotateIn>>,
        #[clap(flatten)]
        options: EndpointRotateSecretOptions,
    },
    /// Get the additional headers to be sent with the webhook.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint get-headers app_abc000000000000000000000000 ep_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example response:
{
  \"headers\": {
    \"X-Example\": \"123\",
    \"X-Foobar\": \"Bar\"
  },
  \"sensitive\": [\"Authorization\"]
}\n")]
    GetHeaders {
        app_id: String,
        id: String,
    },
    /// Set the additional headers to be sent with the webhook.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint set-headers app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"headers\": {
    \"X-Example\": \"123\",
    \"X-Foobar\": \"Bar\"
  }
}\n")]
    SetHeaders {
        app_id: String,
        id: String,
        endpoint_headers_in: crate::json::JsonOf<EndpointHeadersIn>,
    },
    /// Partially set the additional headers to be sent with the webhook.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint patch-headers app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"headers\": {
    \"X-Example\": \"123\",
    \"X-Foobar\": \"Bar\"
  },
  \"deleteHeaders\": [\"...\"]
}\n")]
    PatchHeaders {
        app_id: String,
        id: String,
        endpoint_headers_patch_in: crate::json::JsonOf<EndpointHeadersPatchIn>,
    },
    /// Replays messages to the endpoint.
    ///
    /// Only messages that were created after `since` will be sent.
    /// Messages that were previously sent to the endpoint are not resent.
    ///
    /// A completed task will return a payload like the following:
    /// ```json
    /// {
    ///   "id": "qtask_33qen93MNuelBAq1T9G7eHLJRsF",
    ///   "status": "finished",
    ///   "task": "endpoint.replay",
    ///   "data": {
    ///     "messagesSent": 2
    ///   }
    /// }
    /// ```
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint replay-missing app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"since\": \"2030-01-01T00:00:00Z\",
  \"until\": \"2030-01-01T00:00:00Z\"
}\n\nExample response:
{
  \"id\": \"qtask_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"status\": \"running\",
  \"task\": \"endpoint.replay\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    ReplayMissing {
        app_id: String,
        id: String,
        replay_in: crate::json::JsonOf<ReplayIn>,
        #[clap(flatten)]
        options: EndpointReplayMissingOptions,
    },
    /// Bulk replay messages sent to the endpoint.
    ///
    /// Only messages that were created after `since` will be sent.
    /// This will replay both successful, and failed messages
    ///
    /// A completed task will return a payload like the following:
    /// ```json
    /// {
    ///   "id": "qtask_33qen93MNuelBAq1T9G7eHLJRsF",
    ///   "status": "finished",
    ///   "task": "endpoint.bulk-replay",
    ///   "data": {
    ///     "messagesSent": 2
    ///   }
    /// }
    /// ```
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint bulk-replay app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"since\": \"2030-01-01T00:00:00Z\",
  \"until\": \"2030-01-01T00:00:00Z\",
  \"eventTypes\": [\"...\"],
  \"channel\": \"project_1337\",
  \"tag\": \"project_1337\",
  \"status\": 0,
  \"statusCodeClass\": 0
}\n\nExample response:
{
  \"id\": \"qtask_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"status\": \"running\",
  \"task\": \"endpoint.replay\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    BulkReplay {
        app_id: String,
        id: String,
        bulk_replay_in: crate::json::JsonOf<BulkReplayIn>,
        #[clap(flatten)]
        options: EndpointBulkReplayOptions,
    },
    /// Get basic statistics for the endpoint.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint get-stats app_abc000000000000000000000000 ep_abc000000000000000000000000\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example response:
{
  \"success\": 123,
  \"pending\": 123,
  \"sending\": 123,
  \"fail\": 123,
  \"canceled\": 123
}\n")]
    GetStats {
        app_id: String,
        id: String,
        #[clap(flatten)]
        options: EndpointGetStatsOptions,
    },
    /// Resend all failed messages since a given time.
    ///
    /// Messages that were sent successfully, even if failed initially, are not resent.
    ///
    /// A completed task will return a payload like the following:
    /// ```json
    /// {
    ///   "id": "qtask_33qen93MNuelBAq1T9G7eHLJRsF",
    ///   "status": "finished",
    ///   "task": "endpoint.recover",
    ///   "data": {
    ///     "messagesSent": 2
    ///   }
    /// }
    /// ```
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint recover app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"since\": \"2030-01-01T00:00:00Z\",
  \"until\": \"2030-01-01T00:00:00Z\"
}\n\nExample response:
{
  \"id\": \"qtask_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"status\": \"running\",
  \"task\": \"endpoint.replay\",
  \"updatedAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    Recover {
        app_id: String,
        id: String,
        recover_in: crate::json::JsonOf<RecoverIn>,
        #[clap(flatten)]
        options: EndpointRecoverOptions,
    },
    /// Send an example message for an event.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint send-example app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"eventType\": \"user.signup\",
  \"exampleIndex\": 123
}\n\nExample response:
{
  \"eventId\": \"unique-identifier\",
  \"eventType\": \"user.signup\",
  \"payload\": {
    \"email\": \"test@example.com\",
    \"type\": \"user.created\",
    \"username\": \"test_user\"
  },
  \"channels\": [\"project_123\",\"group_2\"],
  \"id\": \"msg_1srOrx2ZWZBpBUvZwXKQmoEYga2\",
  \"timestamp\": \"2030-01-01T00:00:00Z\",
  \"tags\": [\"...\"],
  \"deliverAt\": \"2030-01-01T00:00:00Z\"
}\n")]
    SendExample {
        app_id: String,
        id: String,
        event_example_in: crate::json::JsonOf<EventExampleIn>,
        #[clap(flatten)]
        options: EndpointSendExampleOptions,
    },
    /// This operation was renamed to `set-transformation`.
    #[command(help_template = concat!(
            "{about-with-newline}\n",
            "{usage-heading} {usage}\n\n",
            "Example: svix endpoint transformation-partial-update app_abc000000000000000000000000 ep_abc000000000000000000000000 {...}\n",
            "{after-help}",
            "\n",
            "{all-args}",
        ))]
    #[command(after_help = "Example body:
{
  \"code\": \"...\",
  \"enabled\": true
}\n")]
    TransformationPartialUpdate {
        app_id: String,
        id: String,
        endpoint_transformation_in: Option<crate::json::JsonOf<EndpointTransformationIn>>,
    },
}

impl EndpointCommands {
    pub async fn exec(
        self,
        client: &Svix,
        color_mode: colored_json::ColorMode,
    ) -> anyhow::Result<()> {
        match self {
            Self::Transformation(args) => {
                args.command.exec(client, color_mode).await?;
            }
            Self::List { app_id, options } => {
                let resp = client.endpoint().list(app_id, Some(options.into())).await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::Create {
                app_id,
                endpoint_in,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .create(app_id, endpoint_in.into_inner(), Some(options.into()))
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::Get { app_id, id } => {
                let resp = client.endpoint().get(app_id, id).await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::Upsert {
                app_id,
                id,
                endpoint_upsert_in,
            } => {
                let resp = client
                    .endpoint()
                    .upsert(app_id, id, endpoint_upsert_in.into_inner())
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::Delete { app_id, id } => {
                client.endpoint().delete(app_id, id).await?;
            }
            Self::Patch {
                app_id,
                id,
                endpoint_patch,
            } => {
                let resp = client
                    .endpoint()
                    .patch(app_id, id, endpoint_patch.unwrap_or_default().into_inner())
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::GetSecret { app_id, id } => {
                let resp = client.endpoint().get_secret(app_id, id).await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::RotateSecret {
                app_id,
                id,
                endpoint_secret_rotate_in,
                options,
            } => {
                client
                    .endpoint()
                    .rotate_secret(
                        app_id,
                        id,
                        endpoint_secret_rotate_in.unwrap_or_default().into_inner(),
                        Some(options.into()),
                    )
                    .await?;
            }
            Self::GetHeaders { app_id, id } => {
                let resp = client.endpoint().get_headers(app_id, id).await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::SetHeaders {
                app_id,
                id,
                endpoint_headers_in,
            } => {
                client
                    .endpoint()
                    .set_headers(app_id, id, endpoint_headers_in.into_inner())
                    .await?;
            }
            Self::PatchHeaders {
                app_id,
                id,
                endpoint_headers_patch_in,
            } => {
                client
                    .endpoint()
                    .patch_headers(app_id, id, endpoint_headers_patch_in.into_inner())
                    .await?;
            }
            Self::ReplayMissing {
                app_id,
                id,
                replay_in,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .replay_missing(app_id, id, replay_in.into_inner(), Some(options.into()))
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::BulkReplay {
                app_id,
                id,
                bulk_replay_in,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .bulk_replay(
                        app_id,
                        id,
                        bulk_replay_in.into_inner(),
                        Some(options.into()),
                    )
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::GetStats {
                app_id,
                id,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .get_stats(app_id, id, Some(options.into()))
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::Recover {
                app_id,
                id,
                recover_in,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .recover(app_id, id, recover_in.into_inner(), Some(options.into()))
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::SendExample {
                app_id,
                id,
                event_example_in,
                options,
            } => {
                let resp = client
                    .endpoint()
                    .send_example(
                        app_id,
                        id,
                        event_example_in.into_inner(),
                        Some(options.into()),
                    )
                    .await?;
                crate::json::print_json_output(&resp, color_mode)?;
            }
            Self::TransformationPartialUpdate {
                app_id,
                id,
                endpoint_transformation_in,
            } => {
                #[allow(deprecated)]
                client
                    .endpoint()
                    .transformation_partial_update(
                        app_id,
                        id,
                        endpoint_transformation_in.unwrap_or_default().into_inner(),
                    )
                    .await?;
            }
        }

        Ok(())
    }
}
