client
import "github.com/SuperBuker/terraform-provider-dns-he-net/client/client"
Index
- Constants
- func getRecordsParams(zoneID uint) map[string]string
- func initResult(_ *resty.Client, resp *resty.Response) (err error)
- func retryCondition(resp *resty.Response, err error) (retry bool)
- func unwrapResult(_ *resty.Client, resp *resty.Response) (err error)
- type Client
- func NewClient(ctx context.Context, authAuth auth.Auth, log logging.Logger, options ...Option) (*Client, error)
- func newClient(ctx context.Context, authAuth auth.Auth, log logging.Logger, options Options) *Client
- func (c *Client) CreateZone(ctx context.Context, name string) (models.Zone, error)
- func (c *Client) DDNS() ddns.Client
- func (c *Client) DeleteRecord(ctx context.Context, record models.RecordX) error
- func (c *Client) DeleteZone(ctx context.Context, zone models.Zone) error
- func (c *Client) GetAccount() string
- func (c *Client) GetRecords(ctx context.Context, zoneID uint) ([]models.Record, error)
- func (c *Client) GetZones(ctx context.Context) ([]models.Zone, error)
- func (c *Client) SetDDNSKey(ctx context.Context, dk models.DDNSKey) (string, error)
- func (c *Client) SetRecord(ctx context.Context, record models.RecordX) (models.RecordX, error)
- func (c *Client) authBasic(ctx context.Context, client *resty.Client) ([]*http.Cookie, error)
- func (c *Client) authOTP(ctx context.Context, client *resty.Client) error
- func (c *Client) authValidation(rc *resty.Client, req *resty.Request) error
- func (c *Client) autheticate(ctx context.Context) ([]*http.Cookie, error)
- func (c *Client) setAccount(resp *resty.Response)
- func (c *Client) statusCheck(_ *resty.Client, resp *resty.Response) (err error)
- func (c *Client) statusCheckLog(resp *resty.Response) error
- type ErrItemNotFound
- type Option
- type Options
Constants
const endpoint = "https://dns.he.net"
const retries = 3
const retryDelay = 30 * time.Second
func getRecordsParams(zoneID uint) map[string]string
getRecordsParams returns the generic query parameters for the record operations.
func initResult(_ *resty.Client, resp *resty.Response) (err error)
initResult initializes the Result field to enable ResultX
func retryCondition(resp *resty.Response, err error) (retry bool)
retryCondition returns true if the request should be retried, includes pause.
func unwrapResult(_ *resty.Client, resp *resty.Response) (err error)
unwrapResult unwraps the ResultX, parses the body if known type and sets the resp.Result
Client is a client for the dns.he.net API.
type Client struct {
// SubObjts
auth auth.Auth
client *resty.Client
log logging.Logger
// State
status auth.Status
account string
// Options
options Options
}
func NewClient(ctx context.Context, authAuth auth.Auth, log logging.Logger, options ...Option) (*Client, error)
NewClient returns a new client, requires a context and an auth.Auth. Autehticates the client against the API.
func newClient(ctx context.Context, authAuth auth.Auth, log logging.Logger, options Options) *Client
newClient returns a new client, handles the go-resty client configuration.
func (c *Client) CreateZone(ctx context.Context, name string) (models.Zone, error)
CreateZone creates a new zone, then returns it, or an error.
func (*Client) DDNS
func (c *Client) DDNS() ddns.Client
func (c *Client) DeleteRecord(ctx context.Context, record models.RecordX) error
DeleteRecord deletes a record, returns an error.
func (c *Client) DeleteZone(ctx context.Context, zone models.Zone) error
DeleteZone deletes a zone, returns an error.
func (c *Client) GetAccount() string
GetAccount returns the account ID.
func (c *Client) GetRecords(ctx context.Context, zoneID uint) ([]models.Record, error)
GetRecords retrieves all records from the API and returns them in a slice.
func (c *Client) GetZones(ctx context.Context) ([]models.Zone, error)
GetZones retrieves all zones from the API and returns them in a slice
func (c *Client) SetDDNSKey(ctx context.Context, dk models.DDNSKey) (string, error)
SetDDNSKey creates or updates a ddns domain key, then returns the result message or an error.
func (c *Client) SetRecord(ctx context.Context, record models.RecordX) (models.RecordX, error)
SetRecord creates or updates a record, then returns it, or an error.
func (c *Client) authBasic(ctx context.Context, client *resty.Client) ([]*http.Cookie, error)
func (*Client) authOTP
func (c *Client) authOTP(ctx context.Context, client *resty.Client) error
func (c *Client) authValidation(rc *resty.Client, req *resty.Request) error
func (c *Client) autheticate(ctx context.Context) ([]*http.Cookie, error)
autheticate authenticates the client against the API on a separated go-resty client, then returns the cookies.
func (c *Client) setAccount(resp *resty.Response)
func (c *Client) statusCheck(_ *resty.Client, resp *resty.Response) (err error)
func (c *Client) statusCheckLog(resp *resty.Response) error
ErrItemNotFound is an error that indicates a resource was not found.
type ErrItemNotFound struct {
Resource string
}
func (*ErrItemNotFound) Error
func (e *ErrItemNotFound) Error() string
func (*ErrItemNotFound) Unwrap
func (e *ErrItemNotFound) Unwrap() []error
type Option struct {
ClientFn func(*resty.Client) *resty.Client
AuthClientFn func(*resty.Client) *resty.Client
DDNSClientFn func(*resty.Client) *resty.Client
LogFn func(logging.Logger) logging.Logger
}
func WithDebug() Option
WithDebug sets the debug mode for the client
func WithProxy(proxy string) Option
WithProxy sets the proxy for the client
func WithUserAgent(ua string) Option
WithUserAgent sets the user agent for the client
type Options []Option
func (opts Options) ApplyAuthClient(client *resty.Client) *resty.Client
func (opts Options) ApplyClient(client *resty.Client) *resty.Client
Proc Options
func (opts Options) ApplyDDNSClient(client *resty.Client) *resty.Client
func (opts Options) ApplyLogger(logger logging.Logger) logging.Logger
Generated by gomarkdoc