model

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 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).
	Domain string `json:"domain" validate:"required"`

	// AlternativeNames is a list of additional domain names.
	AlternativeNames []string `json:"alternative_names,omitempty"`

	// Alias is an optional alternative identifier.
	Alias string `json:"alias,omitempty"`

	// Enabled indicates whether the domain should be active.
	Enabled bool `json:"enabled"`

	// Comment is an optional description.
	Comment string `json:"comment,omitempty"`
}

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

type DomainEntry

type DomainEntry struct {
	pb.DomainEntry

	// Metadata contains additional information about the domain entry.
	Metadata 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.

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

type DomainEntryJSON

type DomainEntryJSON struct {
	*plugin.DomainEntry
}

DomainEntryJSON is a wrapper type for plugin.DomainEntry that provides custom JSON marshaling

func NewDomainEntryJSON

func NewDomainEntryJSON(d *plugin.DomainEntry) *DomainEntryJSON

NewDomainEntryJSON creates a new DomainEntryJSON wrapper

func (DomainEntryJSON) MarshalJSON

func (d DomainEntryJSON) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*DomainEntryJSON) UnmarshalJSON

func (d *DomainEntryJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type DomainResponse

type DomainResponse struct {
	// Success indicates whether the operation was successful.
	Success bool `json:"success"`

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

	// Error contains an error message if the operation failed.
	Error string `json:"error,omitempty"`
}

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

type DomainsResponse

type DomainsResponse struct {
	// Success indicates whether the operation was successful.
	Success bool `json:"success"`

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

	// Error contains an error message if the operation failed.
	Error string `json:"error,omitempty"`
}

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

type Metadata

type Metadata map[string]any

func MetadataFromProto

func MetadataFromProto(resp *pb.GetMetadataResponse) Metadata

type UpdateDomainRequest

type UpdateDomainRequest struct {
	// AlternativeNames is a list of additional domain names.
	AlternativeNames []string `json:"alternative_names,omitempty"`

	// Alias is an optional alternative identifier.
	Alias string `json:"alias,omitempty"`

	// Enabled indicates whether the domain should be active.
	Enabled bool `json:"enabled"`

	// Comment is an optional description.
	Comment string `json:"comment,omitempty"`
}

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

Jump to

Keyboard shortcuts

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