refactor: enhance JSON struct tags for various data models in backend and memory store. Update fields in ModulePatch, CDNSource, ASEntry, DomainEntry, IPRangeEntry, DohProfile, Community, and BGPPeer to improve API response formatting and consistency.
CI / changes (push) Successful in 5s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 24s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Has been skipped
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 13s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 1m2s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 1m35s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m24s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m29s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m25s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m16s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m27s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m25s

This commit is contained in:
Denozordec
2026-04-05 23:13:51 +07:00
parent d4282c270b
commit 4a860a088e
2 changed files with 80 additions and 80 deletions
+65 -65
View File
@@ -80,44 +80,44 @@ type Backend interface {
// ModulePatch is a partial update for module. // ModulePatch is a partial update for module.
type ModulePatch struct { type ModulePatch struct {
Name *string Name *string `json:"name,omitempty"`
Enabled *bool Enabled *bool `json:"enabled,omitempty"`
Priority *int Priority *int `json:"priority,omitempty"`
RefreshIntervalSec *int RefreshIntervalSec *int `json:"refresh_interval_sec,omitempty"`
CronExpr *string CronExpr *string `json:"cron_expr,omitempty"`
DefaultCommunityID *string DefaultCommunityID *string `json:"default_community_id,omitempty"`
DohProfileID *string DohProfileID *string `json:"doh_profile_id,omitempty"`
} }
// CDNSource is a row under a CDN module. // CDNSource is a row under a CDN module.
type CDNSource struct { type CDNSource struct {
ID string ID string `json:"id,omitempty"`
ModuleID string ModuleID string `json:"module_id,omitempty"`
SourceKind string SourceKind string `json:"source_kind"`
URL string URL string `json:"url"`
Etag string Etag string `json:"etag"`
RefreshIntervalSec *int RefreshIntervalSec *int `json:"refresh_interval_sec"`
CommunityID *string CommunityID *string `json:"community_id"`
} }
type CDNSourcePatch struct { type CDNSourcePatch struct {
SourceKind *string SourceKind *string `json:"source_kind,omitempty"`
URL *string URL *string `json:"url,omitempty"`
Etag *string Etag *string `json:"etag,omitempty"`
RefreshIntervalSec *int RefreshIntervalSec *int `json:"refresh_interval_sec,omitempty"`
CommunityID *string CommunityID *string `json:"community_id,omitempty"`
} }
type ASEntry struct { type ASEntry struct {
ID string ID string `json:"id,omitempty"`
ModuleID string ModuleID string `json:"module_id,omitempty"`
ASN int64 ASN int64 `json:"asn"`
CommunityID *string CommunityID *string `json:"community_id"`
} }
type ASEntryPatch struct { type ASEntryPatch struct {
ASN *int64 ASN *int64 `json:"asn,omitempty"`
CommunityID *string CommunityID *string `json:"community_id,omitempty"`
} }
// ValidASN reports whether n is a usable BGP ASN (1..4294967295). // ValidASN reports whether n is a usable BGP ASN (1..4294967295).
@@ -126,73 +126,73 @@ func ValidASN(n int64) bool {
} }
type DomainEntry struct { type DomainEntry struct {
ID string ID string `json:"id,omitempty"`
ModuleID string ModuleID string `json:"module_id,omitempty"`
FQDN string FQDN string `json:"fqdn"`
CommunityID *string CommunityID *string `json:"community_id"`
} }
type DomainEntryPatch struct { type DomainEntryPatch struct {
FQDN *string FQDN *string `json:"fqdn,omitempty"`
CommunityID *string CommunityID *string `json:"community_id,omitempty"`
} }
type IPRangeEntry struct { type IPRangeEntry struct {
ID string ID string `json:"id,omitempty"`
ModuleID string ModuleID string `json:"module_id,omitempty"`
Prefix string Prefix string `json:"prefix"`
CommunityID *string CommunityID *string `json:"community_id"`
} }
type IPRangePatch struct { type IPRangePatch struct {
Prefix *string Prefix *string `json:"prefix,omitempty"`
CommunityID *string CommunityID *string `json:"community_id,omitempty"`
} }
type DohProfile struct { type DohProfile struct {
ID string ID string `json:"id,omitempty"`
TenantID string TenantID string `json:"tenant_id,omitempty"`
Name string Name string `json:"name"`
URL string URL string `json:"url"`
TimeoutMs *int TimeoutMs *int `json:"timeout_ms"`
SecretRef *string SecretRef *string `json:"vault_secret_ref"`
} }
type DohProfilePatch struct { type DohProfilePatch struct {
Name *string Name *string `json:"name,omitempty"`
URL *string URL *string `json:"url,omitempty"`
TimeoutMs *int TimeoutMs *int `json:"timeout_ms,omitempty"`
SecretRef *string SecretRef *string `json:"vault_secret_ref,omitempty"`
} }
type Community struct { type Community struct {
ID string ID string `json:"id,omitempty"`
TenantID string TenantID string `json:"tenant_id,omitempty"`
Name string Name string `json:"name"`
Kind string Kind string `json:"kind"`
ValueJSON string ValueJSON string `json:"value_json"`
} }
type CommunityPatch struct { type CommunityPatch struct {
Name *string Name *string `json:"name,omitempty"`
Kind *string Kind *string `json:"kind,omitempty"`
ValueJSON *string ValueJSON *string `json:"value_json,omitempty"`
} }
type PeerPatch struct { type PeerPatch struct {
Neighbor *string Neighbor *string `json:"neighbor,omitempty"`
RemoteASN *int64 RemoteASN *int64 `json:"remote_asn,omitempty"`
SpeakerID *string SpeakerID *string `json:"bgp_speaker_id,omitempty"`
Enabled *bool Enabled *bool `json:"enabled,omitempty"`
Name *string Name *string `json:"name,omitempty"`
SessionState *string SessionState *string `json:"session_state,omitempty"`
PoliciesJSON *string PoliciesJSON *string `json:"policies_json,omitempty"`
} }
type SpeakerPatch struct { type SpeakerPatch struct {
Role *string Role *string `json:"role,omitempty"`
Endpoint *string Endpoint *string `json:"endpoint,omitempty"`
MetaJSON *string MetaJSON *string `json:"meta_json,omitempty"`
} }
// PrefixRow is one materialized prefix for GET /revisions/.../prefixes. // PrefixRow is one materialized prefix for GET /revisions/.../prefixes.
+15 -15
View File
@@ -89,24 +89,24 @@ type Revision struct {
// BGPPeer maps to bgp_peer (+ display fields in meta). // BGPPeer maps to bgp_peer (+ display fields in meta).
type BGPPeer struct { type BGPPeer struct {
ID string ID string `json:"id,omitempty"`
TenantID string TenantID string `json:"tenant_id,omitempty"`
SpeakerID *string SpeakerID *string `json:"bgp_speaker_id"`
Name string Name string `json:"name"`
Neighbor string Neighbor string `json:"neighbor"`
RemoteASN int64 RemoteASN int64 `json:"remote_asn"`
Enabled bool Enabled bool `json:"enabled"`
SessionState string SessionState string `json:"session_state"`
PoliciesJSON string PoliciesJSON string `json:"policies_json"`
} }
type Speaker struct { type Speaker struct {
ID string ID string `json:"id,omitempty"`
TenantID string TenantID string `json:"tenant_id,omitempty"`
Role string Role string `json:"role"`
Endpoint string Endpoint string `json:"endpoint"`
LastAppliedRevisionID *string LastAppliedRevisionID *string `json:"last_applied_revision_id"`
MetaJSON string MetaJSON string `json:"meta_json"`
} }
func NewMemory() *Memory { func NewMemory() *Memory {