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

Code before:
                    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 {
                let respone = client.api_v3_configure_token_delete(&token_name).await;
                if let Err(e) = respone {
                    match e {
                        influxdb3_client::Error::ApiError { code, ref message } => {
                            if code == StatusCode::METHOD_NOT_ALLOWED
                                && message == "cannot delete operator token"
                            {
                                println!(
                                    "Cannot delete operator token, to regenerate an operator token, use `influxdb3 create token --admin --regenerate --token $TOKEN`"
                                );
                                return Ok(());
                            } else {
                                return Err(Box::new(e));
                            }
                        }
                        _ => {
                            return Err(Box::new(e));
                        }
                    }
                }
                println!("Token {:?} deleted successfully", &token_name);
            }
        }
    }
    Ok(())
}


Review comment (suggestion):
The operator token "_admin" is required cannot be deleted. To regenerate an operator token, use `influxdb3 create token --admin --regenerate --token $TOKEN`.

Code after:
                    &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(())
}