Repository: influxdata/influxdb
File: influxdb3/src/commands/delete.rs (Rust)

Code before:
                println!(
                    "Table {:?}.{:?} deleted successfully",
                    &database_name, &table_name
                );
            }
        }
        SubCommand::Trigger(TriggerConfig {
            influxdb3_config: InfluxDb3Config { database_name, .. },
            trigger_name,
            force,
            ..
        }) => {
            client
                .api_v3_configure_processing_engine_trigger_delete(
                    database_name,
                    &trigger_name,
                    force,
                )
                .await?;
            println!("Trigger {} deleted successfully", trigger_name);
        }
        SubCommand::Token(TokenConfig { token_name, .. }) => {
            println!(
                "Are you sure you want to delete {:?}? Enter 'yes' to confirm",
                token_name
            );
            let mut confirmation = String::new();
            let _ = io::stdin().read_line(&mut confirmation);
            if confirmation.trim() != "yes" {
                println!("Cannot delete token without confirmation");
            } else {
                client.api_v3_configure_token_delete(&token_name).await?;

                println!("Token {:?} deleted successfully", &token_name);
            }
        }
    }
    Ok(())
}


Review comment (refactor):
@praveen-influx - the [spec](https://docs.google.com/document/d/18lJqRgW7VMm0WExRNuOmWh7NlagN_V7g6E_2gFITKHY/edit?tab=t.0#heading=h.z4mcivxvuk6d) does not say whether the 'name' of a token is immutable or mutable. I recall thinking that since the actual operations under the hood would be on the immutable 'id', then names would be mutable.

If names are immutable, this `if token_name == "_admin"` is ok. If they are not, or we plan to change them in the future, this could be a problem. If they are (or we want them to become) mutable, we should:
* not allow the operator token (named `_admin`) to be renamed
* not allow duplicate token names (do we already enforce this?)

Code after:
                println!(
                    "Table {:?}.{:?} deleted successfully",
                    &database_name, &table_name
                );
            }
        }
        SubCommand::Trigger(TriggerConfig {
            influxdb3_config: InfluxDb3Config { database_name, .. },
            trigger_name,
            force,
            ..
        }) => {
            client
                .api_v3_configure_processing_engine_trigger_delete(
                    database_name,
                    &trigger_name,
                    force,
                )
                .await?;
            println!("Trigger {} deleted successfully", trigger_name);
        }
        SubCommand::Token(TokenConfig { token_name, .. }) => {
            if token_name == "_admin" {
                println!(
                    "The operator token \"_admin\" is required and cannot be deleted. To regenerate an operator token, use: influxdb3 create token --admin --regenerate --token [TOKEN]"
                );
                return Ok(());
            }

            println!(
                "Are you sure you want to delete {:?}? Enter 'yes' to confirm",
                token_name
            );
            let mut confirmation = String::new();
            let _ = io::stdin().read_line(&mut confirmation);
            if confirmation.trim() != "yes" {
                println!("Cannot delete token without confirmation");
            } else {
                client.api_v3_configure_token_delete(&token_name).await?;
                println!("Token {:?} deleted successfully", &token_name);
            }
        }
    }
    Ok(())
}