#!/bin/bash

# Show network service details
port_show_network_service()
{
    local app_name="$1"
    local service_name="$2"
    
    local sql="SELECT ip_address, internal_port, external_port, service_type, access_type, domain_name, category FROM network_services WHERE app_name = '$app_name' AND service_name = '$service_name' AND status = 'active';"
    
    while IFS='|' read -r ip_address internal_port external_port service_type access_type domain_name category; do
        echo "📋 Network Service Details:"
        echo "   🌐 IP Address: $ip_address"
        echo "   🔌 Internal Port: $internal_port"
        if [[ -n "$external_port" && "$external_port" != "NULL" ]]; then
            echo "   🔌 External Port: $external_port"
            echo "   🔗 URL: http://$ip_address:$external_port"
        fi
        echo "   🏷️  Service Type: $service_type"
        echo "   🔐 Access Type: $access_type"
        if [[ -n "$domain_name" && "$domain_name" != "NULL" ]]; then
            echo "   🌍 Domain: $domain_name"
        fi
        echo "   📂 Category: $category"
        echo ""
    done < <(sqlite3 "$docker_dir/$db_file" "$sql" 2>/dev/null)
}
