Documentation
¶
Overview ¶
Package dnscale provides a typed client for the DNScale API.
Index ¶
- Constants
- func Ptr[T any](value T) *T
- type APIError
- type Client
- type CreateRecordRequest
- type CreateZoneRequest
- type Options
- type PageOptions
- type ProtocolError
- type RateLimitError
- type Record
- type RecordType
- type RecordsService
- func (s *RecordsService) Create(ctx context.Context, zoneID string, body CreateRecordRequest) (*Record, error)
- func (s *RecordsService) Delete(ctx context.Context, zoneID, recordID string) error
- func (s *RecordsService) DeleteByName(ctx context.Context, zoneID, name string, kind RecordType, content *string) error
- func (s *RecordsService) Get(ctx context.Context, zoneID, recordID string) (*Record, error)
- func (s *RecordsService) Iter(ctx context.Context, zoneID string, pageSize int) iter.Seq2[Record, error]
- func (s *RecordsService) List(ctx context.Context, zoneID string, options PageOptions) (*api.RecordsData, error)
- func (s *RecordsService) Update(ctx context.Context, zoneID, recordID string, body CreateRecordRequest) (*Record, error)
- func (s *RecordsService) UpdateByName(ctx context.Context, zoneID, name string, kind RecordType, ...) (*Record, error)
- type UpdateRecordByNameRequest
- type UpdateZoneRequest
- type Zone
- type ZonesService
- func (s *ZonesService) Create(ctx context.Context, body CreateZoneRequest) (*Zone, error)
- func (s *ZonesService) Delete(ctx context.Context, zoneID string) error
- func (s *ZonesService) Get(ctx context.Context, zoneID string) (*Zone, error)
- func (s *ZonesService) Iter(ctx context.Context, pageSize int) iter.Seq2[Zone, error]
- func (s *ZonesService) List(ctx context.Context, options PageOptions) (*api.ZonesData, error)
- func (s *ZonesService) Update(ctx context.Context, zoneID string, body UpdateZoneRequest) (*Zone, error)
Examples ¶
Constants ¶
View Source
const DefaultBaseURL = "https://api.dnscale.eu/v1"
View Source
const Version = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Code string
Message string
RequestID string
Details json.RawMessage
}
APIError retains HTTP and API metadata, even for non-JSON gateway failures.
type Client ¶
type Client struct {
API *api.ClientWithResponses
Zones *ZonesService
Records *RecordsService
// contains filtered or unexported fields
}
Client exposes convenient resources and every generated API operation.
func New ¶
Example ¶
package main
import (
"context"
"fmt"
dnscale "github.com/dnscaleou/dnscale-go"
)
func main() {
client, err := dnscale.New(dnscale.Options{APIKey: "example-key"})
if err != nil {
panic(err)
}
defer client.Close()
for zone, err := range client.Zones.Iter(context.Background(), 100) {
if err != nil {
panic(err)
}
fmt.Println(zone.Name)
}
}
Output:
type CreateRecordRequest ¶
type CreateRecordRequest = api.CreateRecordRequest
Example ¶
package main
import (
"fmt"
dnscale "github.com/dnscaleou/dnscale-go"
"github.com/oapi-codegen/nullable"
)
func main() {
request := dnscale.CreateRecordRequest{
Name: "www", Type: "A", Content: "192.0.2.10", Ttl: dnscale.Ptr(300),
Comment: nullable.NewNullableWithValue("managed by application"),
}
fmt.Println(request.Name)
}
Output: www
type CreateZoneRequest ¶
type CreateZoneRequest = api.CreateZoneRequest
type Options ¶
type Options struct {
APIKey string
BaseURL string
HTTPClient *http.Client
// Timeout covers one operation including retries; zero defaults to 10 seconds.
Timeout time.Duration
// MaxRetries defaults to 2. Use Ptr(0) to disable retries.
MaxRetries *int
// RetryBackoff defaults to 250ms. Server Retry-After takes precedence.
RetryBackoff time.Duration
}
Options configures authentication, transport, and conservative read retries.
type PageOptions ¶
type ProtocolError ¶
type ProtocolError struct{ Message string }
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string
type RateLimitError ¶
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
type RecordType ¶
type RecordType = api.RecordType
type RecordsService ¶
type RecordsService struct {
// contains filtered or unexported fields
}
func (*RecordsService) Create ¶
func (s *RecordsService) Create(ctx context.Context, zoneID string, body CreateRecordRequest) (*Record, error)
func (*RecordsService) Delete ¶
func (s *RecordsService) Delete(ctx context.Context, zoneID, recordID string) error
func (*RecordsService) DeleteByName ¶
func (s *RecordsService) DeleteByName(ctx context.Context, zoneID, name string, kind RecordType, content *string) error
DeleteByName deletes one value when content is non-nil; nil deletes the WHOLE RRset.
func (*RecordsService) List ¶
func (s *RecordsService) List(ctx context.Context, zoneID string, options PageOptions) (*api.RecordsData, error)
func (*RecordsService) Update ¶
func (s *RecordsService) Update(ctx context.Context, zoneID, recordID string, body CreateRecordRequest) (*Record, error)
func (*RecordsService) UpdateByName ¶
func (s *RecordsService) UpdateByName(ctx context.Context, zoneID, name string, kind RecordType, body UpdateRecordByNameRequest, oldContent *string) (*Record, error)
UpdateByName selects an existing value using oldContent when non-nil.
type UpdateRecordByNameRequest ¶
type UpdateRecordByNameRequest = api.UpdateRecordByNameRequest
type UpdateZoneRequest ¶
type UpdateZoneRequest = api.UpdateZoneRequest
type ZonesService ¶
type ZonesService struct {
// contains filtered or unexported fields
}
func (*ZonesService) Create ¶
func (s *ZonesService) Create(ctx context.Context, body CreateZoneRequest) (*Zone, error)
func (*ZonesService) Delete ¶
func (s *ZonesService) Delete(ctx context.Context, zoneID string) error
func (*ZonesService) Iter ¶
Iter lazily traverses zones. Stop range iteration to avoid further requests. Listing is not an atomic snapshot under concurrent writes.
func (*ZonesService) List ¶
func (s *ZonesService) List(ctx context.Context, options PageOptions) (*api.ZonesData, error)
func (*ZonesService) Update ¶
func (s *ZonesService) Update(ctx context.Context, zoneID string, body UpdateZoneRequest) (*Zone, error)
Click to show internal directories.
Click to hide internal directories.