refactor: clean code

This commit is contained in:
Fu Diwei
2025-04-22 21:18:16 +08:00
parent 8fe942d8d5
commit 3189e65bad
243 changed files with 545 additions and 507 deletions

View File

@@ -0,0 +1,93 @@
package dtos
import "encoding/json"
type CDNConfiguration struct {
ConfigurationID string `json:"id"`
EnvironmentID string `json:"environment_id"`
Rules json.RawMessage `json:"rules"`
Origins []Origin `json:"origins"`
Hostnames []Hostname `json:"hostnames"`
Experiments *[]string `json:"experiments,omitempty"`
EdgeFunctionsSources *map[string]string `json:"edge_functions_sources,omitempty"`
EdgeFunctionInitScript *string `json:"edge_function_init_script,omitempty"`
}
type Origin struct {
Name string `json:"name"`
Type *string `json:"type,omitempty"`
Hosts []Host `json:"hosts"`
Balancer *string `json:"balancer,omitempty"`
OverrideHostHeader *string `json:"override_host_header,omitempty"`
Shields *Shields `json:"shields,omitempty"`
PciCertifiedShields *bool `json:"pci_certified_shields,omitempty"`
TLSVerify *TLSVerify `json:"tls_verify,omitempty"`
Retry *Retry `json:"retry,omitempty"`
}
type Host struct {
Weight *int64 `json:"weight,omitempty"`
DNSMaxTTL *int64 `json:"dns_max_ttl,omitempty"`
DNSPreference *string `json:"dns_preference,omitempty"`
MaxHardPool *int64 `json:"max_hard_pool,omitempty"`
DNSMinTTL *int64 `json:"dns_min_ttl,omitempty"`
Location *[]Location `json:"location,omitempty"`
MaxPool *int64 `json:"max_pool,omitempty"`
Balancer *string `json:"balancer,omitempty"`
Scheme *string `json:"scheme,omitempty"`
OverrideHostHeader *string `json:"override_host_header,omitempty"`
SNIHintAndStrictSanCheck *string `json:"sni_hint_and_strict_san_check,omitempty"`
UseSNI *bool `json:"use_sni,omitempty"`
}
type Location struct {
Port *int64 `json:"port,omitempty"`
Hostname *string `json:"hostname,omitempty"`
}
type Shields struct {
Apac *string `json:"apac,omitempty"`
Emea *string `json:"emea,omitempty"`
USWest *string `json:"us_west,omitempty"`
USEast *string `json:"us_east,omitempty"`
}
type TLSVerify struct {
UseSNI *bool `json:"use_sni,omitempty"`
SNIHintAndStrictSanCheck *string `json:"sni_hint_and_strict_san_check,omitempty"`
AllowSelfSignedCerts *bool `json:"allow_self_signed_certs,omitempty"`
PinnedCerts *[]string `json:"pinned_certs,omitempty"`
}
type Retry struct {
StatusCodes *[]int64 `json:"status_codes,omitempty"`
IgnoreRetryAfterHeader *bool `json:"ignore_retry_after_header,omitempty"`
AfterSeconds *int64 `json:"after_seconds,omitempty"`
MaxRequests *int64 `json:"max_requests,omitempty"`
MaxWaitSeconds *int64 `json:"max_wait_seconds,omitempty"`
}
type Hostname struct {
Hostname *string `json:"hostname,omitempty"`
DefaultOriginName *string `json:"default_origin_name,omitempty"`
ReportCode *int64 `json:"report_code,omitempty"`
TLS *TLS `json:"tls,omitempty"`
Directory *string `json:"directory,omitempty"`
}
type TLS struct {
NPN *bool `json:"npn,omitempty"`
ALPN *bool `json:"alpn,omitempty"`
Protocols *string `json:"protocols,omitempty"`
UseSigAlgs *bool `json:"use_sigalgs,omitempty"`
SNI *bool `json:"sni,omitempty"`
SniStrict *bool `json:"sni_strict,omitempty"`
SniHostMatch *bool `json:"sni_host_match,omitempty"`
ClientRenegotiation *bool `json:"client_renegotiation,omitempty"`
Options *string `json:"options,omitempty"`
CipherList *string `json:"cipher_list,omitempty"`
NamedCurve *string `json:"named_curve,omitempty"`
OCSP *bool `json:"oscp,omitempty"`
PEM *string `json:"pem,omitempty"`
CA *string `json:"ca,omitempty"`
}

View File

@@ -0,0 +1,29 @@
package dtos
import (
"time"
)
type Environment struct {
Type string `json:"@type"`
IdLink string `json:"@id"`
Id string `json:"id"`
PropertyID string `json:"property_id"`
LegacyAccountNumber string `json:"legacy_account_number"`
Name string `json:"name"`
CanMembersDeploy bool `json:"can_members_deploy"`
OnlyMaintainersCanDeploy bool `json:"only_maintainers_can_deploy"`
HttpRequestLogging bool `json:"http_request_logging"`
DefaultDomainName string `json:"default_domain_name"`
PciCompliance bool `json:"pci_compliance"`
DnsDomainName string `json:"dns_domain_name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type EnvironmentsResponse struct {
Type string `json:"@type"`
Id string `json:"@id"`
TotalItems int `json:"total_items"`
Items []Environment `json:"items"`
}

View File

@@ -0,0 +1,18 @@
package dtos
import "time"
type Property struct {
IdLink string `json:"@id"`
Id string `json:"id"`
OrganizationID string `json:"organization_id"`
Slug string `json:"slug"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Properties struct {
ID string `json:"@id"`
TotalItems int `json:"total_items"`
Items []Property `json:"items"`
}

View File

@@ -0,0 +1,18 @@
package dtos
import "time"
type PurgeResponse struct {
ID string `json:"id"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
CompletedAt time.Time `json:"completed_at"`
ProgressPercentage float32 `json:"progress_percentage"`
}
type PurgeRequest struct {
EnvironmentID string `json:"environment_id"`
PurgeType string `json:"purge_type"`
Values []string `json:"values"`
Hostname *string `json:"hostname"`
}

View File

@@ -0,0 +1,30 @@
package dtos
type TLSCertResponse struct {
ID string `json:"id"`
EnvironmentID string `json:"environment_id"`
PrimaryCert string `json:"primary_cert"`
IntermediateCert string `json:"intermediate_cert"`
Expiration string `json:"expiration"`
Status string `json:"status"`
Generated bool `json:"generated"`
Serial string `json:"serial"`
CommonName string `json:"common_name"`
AlternativeNames []string `json:"alternative_names"`
ActivationError string `json:"activation_error"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type UploadTlsCertRequest struct {
EnvironmentID string `json:"environment_id"`
PrimaryCert string `json:"primary_cert"`
IntermediateCert string `json:"intermediate_cert"`
PrivateKey string `json:"private_key"`
}
type TLSCertSResponse struct {
EnvironmentID string `json:"environment_id"`
TotalItems int32 `json:"total_items"`
Certificates []TLSCertResponse `json:"items"`
}