model

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package model provides data structures and validation logic for the dehydrated-api-go application. It includes domain entry models, request/response structures, and protobuf conversion utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidDomain

func IsValidDomain(domain string) bool

IsValidDomain checks if a string is a valid domain name or wildcard domain. It validates the domain against a regular expression that enforces the following rules: - Domain parts can contain letters, numbers, and hyphens - Hyphens cannot be at the start or end of a part - At least one dot is required (except for wildcard domains) - Optional wildcard at the start of the first part - TLD must be at least 2 characters Returns true if the domain is valid, false otherwise.

func IsValidDomainEntry

func IsValidDomainEntry(entry *DomainEntry) bool

IsValidDomainEntry checks if a DomainEntry is valid by validating its domain field. It ensures that the domain name follows the standard domain naming conventions. Returns true if the domain entry is valid, false otherwise.

Types

type CreateDomainRequest

type CreateDomainRequest struct {
	// Domain is the primary domain name (required).
	// @Description Primary domain name (required)
	// @required
	Domain string `json:"domain" validate:"required" example:"example.com"`

	// AlternativeNames is a list of additional domain names.
	// @Description List of additional domain names (e.g., "www.example.com")
	AlternativeNames []string `json:"alternative_names,omitempty" example:"www.example.com,api.example.com"`

	// Alias is an optional alternative identifier.
	// @Description Optional alternative identifier for the domain
	Alias string `json:"alias,omitempty" example:"my-domain"`

	// Enabled indicates whether the domain should be active.
	// @Description Whether the domain is enabled for certificate issuance
	Enabled bool `json:"enabled" example:"true"`

	// Comment is an optional description.
	// @Description Optional description or comment for the domain
	Comment string `json:"comment,omitempty" example:"Production domain for web application"`
}

CreateDomainRequest represents a request to create a new domain entry. It contains all the necessary fields to create a new domain configuration. @Description Request to create a new domain entry

type DomainEntry

type DomainEntry struct {
	pb.DomainEntry

	// Metadata contains additional information about the domain entry.
	// @Description Additional metadata about the domain entry
	Metadata *pb.Metadata `json:"metadata,omitempty"`
}

DomainEntry represents a domain configuration entry in the dehydrated system. It contains all the necessary information for managing a domain's SSL certificate. @Description Domain configuration entry for SSL certificate management

func (*DomainEntry) MarshalJSON

func (e *DomainEntry) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface to ensure all fields are included

func (*DomainEntry) PathName

func (e *DomainEntry) PathName() string

func (*DomainEntry) SetMetadata added in v0.0.14

func (e *DomainEntry) SetMetadata(m *pb.Metadata)

type DomainResponse

type DomainResponse struct {
	// Success indicates whether the operation was successful.
	// @Description Whether the operation was successful
	Success bool `json:"success" example:"true"`

	// Data contains the domain entry if the operation was successful.
	// @Description Domain entry data if the operation was successful
	Data *DomainEntry `json:"data,omitempty"`

	// Error contains an error message if the operation failed.
	// @Description Error message if the operation failed
	Error string `json:"error,omitempty" example:"Domain not found"`
}

DomainResponse represents a response containing a single domain entry. It includes a success flag, the domain data, and an optional error message. @Description Response containing a single domain entry

type DomainsResponse

type DomainsResponse struct {
	// Success indicates whether the operation was successful.
	// @Description Whether the operation was successful
	Success bool `json:"success" example:"true"`

	// Data contains the list of domain entries if the operation was successful.
	// @Description List of domain entries if the operation was successful
	Data []*DomainEntry `json:"data,omitempty"`

	// Error contains an error message if the operation failed.
	// @Description Error message if the operation failed
	Error string `json:"error,omitempty" example:"Failed to load domains"`
}

DomainsResponse represents a response containing multiple domain entries. It includes a success flag, a list of domain data, and an optional error message. @Description Response containing multiple domain entries

type UpdateDomainRequest

type UpdateDomainRequest struct {
	// AlternativeNames is a list of additional domain names.
	// @Description List of additional domain names (e.g., "www.example.com")
	AlternativeNames *[]string `json:"alternative_names,omitempty" example:"www.example.com,api.example.com"`

	// Alias is an optional alternative identifier.
	// @Description Optional alternative identifier for the domain
	Alias *string `json:"alias,omitempty" example:"my-domain"`

	// Enabled indicates whether the domain should be active.
	// @Description Whether the domain is enabled for certificate issuance
	Enabled *bool `json:"enabled,omitempty" example:"true"`

	// Comment is an optional description.
	// @Description Optional description or comment for the domain
	Comment *string `json:"comment,omitempty" example:"Production domain for web application"`
}

UpdateDomainRequest represents a request to update an existing domain entry. It contains the fields that can be modified for an existing domain. @Description Request to update an existing domain entry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL