package models

import "time"

type Connection struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Host        string    `json:"host"`
	Port        int       `json:"port"`
	Database    string    `json:"database"`
	Username    string    `json:"username"`
	Password    string    `json:"password,omitempty"`
	SSLMode     string    `json:"sslMode"`
	IsConnected bool      `json:"isConnected"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

type ConnectionRequest struct {
	Name     string `json:"name" binding:"required"`
	Host     string `json:"host" binding:"required"`
	Port     int    `json:"port" binding:"required"`
	Database string `json:"database"`
	Username string `json:"username" binding:"required"`
	Password string `json:"password"`
	SSLMode  string `json:"sslMode"`
}

type TestConnectionRequest struct {
	Host     string `json:"host" binding:"required"`
	Port     int    `json:"port" binding:"required"`
	Database string `json:"database"`
	Username string `json:"username" binding:"required"`
	Password string `json:"password"`
	SSLMode  string `json:"sslMode"`
}

type SwitchDatabaseRequest struct {
	Database string `json:"database" binding:"required"`
}

type CreateDatabaseRequest struct {
	Name     string `json:"name" binding:"required"`
	Owner    string `json:"owner"`
	Template string `json:"template"`
	Encoding string `json:"encoding"`
}

type DropDatabaseRequest struct {
	Force bool `json:"force"`
}

// DefaultDatabase is the fallback database name used when a connection is created
// without specifying one. Postgres always requires a database to authenticate against;
// `postgres` is the conventional maintenance database guaranteed to exist.
const DefaultDatabase = "postgres"
