dnsimplex

package
v0.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dnsimplex contains utility functions for working with the DNSimple API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](
	ctx context.Context,
	list func(dnsimple.ListOptions) (*dnsimple.Pagination, []T, error),
) ([]T, error)

All returns a slice of all the values returned by list.

list is called once for each page of results.

func Each

func Each[T any](
	_ context.Context,
	list func(dnsimple.ListOptions) (*dnsimple.Pagination, []T, error),
	fn func(T) (bool, error),
) error

Each calls fn for each value returned by list.

list is called once for each page of results.

If fn returns false, the iteration stops.

func Errorf added in v0.4.4

func Errorf(format string, args ...any) error

Errorf returns an error that formats according to a format specifier.

func Find

func Find[T, V any](
	ctx context.Context,
	list func(dnsimple.ListOptions) (*dnsimple.Pagination, []T, error),
	fn func(T) (V, bool, error),
) (result V, ok bool, err error)

Find calls fn for each value returned by list until fn returns true.

It returns the result of fn.

func First

func First[T any](
	ctx context.Context,
	list func(dnsimple.ListOptions) (*dnsimple.Pagination, []T, error),
	pred func(T) bool,
) (T, bool, error)

First returns the first value returned by list for which pred returns true.

list is called once for each page of results.

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound returns nil if err is a non-found error, otherwise it returns err unchanged.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if err is an error response from dnsimple.com that indicates that the requested resource does not exist.

func One

func One[T any](
	ctx context.Context,
	list func(dnsimple.ListOptions) (*dnsimple.Pagination, []T, error),
) (T, bool, error)

One returns the first value returned by list.

func RecordHasAttributes

func RecordHasAttributes(
	r dnsimple.ZoneRecord,
	a dnsimple.ZoneRecordAttributes,
) bool

RecordHasAttributes returns true if the attributes of r are equivalent to the values in a.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL