base.go raw
1 package v2
2
3 import (
4 "context"
5 "io"
6 "net/http"
7 )
8
9 const (
10 rootPath = "/zones"
11 zonePath = "/zones/%v"
12 zonePathUpdateState = "/zones/%v/state"
13 zonePathUpdateProtection = "/zones/%v/protection"
14 rrsetPath = "/zones/%v/rrset"
15 singleRRSetPath = "/zones/%v/rrset/%v"
16 )
17
18 type (
19 DNSManager[Z any, S any] interface {
20 ZoneManager[Z]
21 RRSetManager[S]
22 }
23 DNSClient[Z any, S any] interface {
24 DNSManager[Z, S]
25 WithHeaders(headers http.Header) DNSClient[Z, S]
26 }
27
28 ZoneManager[Z any] interface {
29 GetZone(ctx context.Context, zoneID string, options *map[string]string) (*Z, error)
30 ListZones(ctx context.Context, options *map[string]string) (Listable[Z], error)
31 CreateZone(ctx context.Context, zone Creatable) (*Z, error)
32 DeleteZone(ctx context.Context, zoneID string) error
33 UpdateZoneState(ctx context.Context, zoneID string, disabled bool) error
34 UpdateZoneComment(ctx context.Context, zoneID string, comment string) error
35 UpdateProtectionState(ctx context.Context, zoneID string, protected bool) error
36 }
37
38 RRSetManager[S any] interface {
39 CreateRRSet(ctx context.Context, zoneID string, rrset Creatable) (*S, error)
40 GetRRSet(ctx context.Context, zoneID, rrsetID string) (*S, error)
41 ListRRSets(ctx context.Context, zoneID string, options *map[string]string) (Listable[S], error)
42 UpdateRRSet(ctx context.Context, zoneID, rrsetID string, rrset Updatable) error
43 DeleteRRSet(ctx context.Context, zoneID, rrsetID string) error
44 }
45
46 Listable[T any] interface {
47 GetCount() int
48 GetNextOffset() int
49 GetItems() []*T
50 }
51
52 Creatable interface {
53 CreationForm() (io.Reader, error)
54 }
55
56 Updatable interface {
57 UpdateForm() (io.Reader, error)
58 }
59 )
60