Documentation ¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- type CNAMERecord
- type CNAMERecordList
- type CNAMERecordsListResponse
- type Client
- func (c Client) CreateCNAMERecord(ctx context.Context, record *CNAMERecord) (*CNAMERecord, error)
- func (c Client) CreateDNSRecord(ctx context.Context, record *DNSRecord) (*DNSRecord, error)
- func (c Client) CreateGroup(ctx context.Context, gr *GroupCreateRequest) (*Group, error)
- func (c Client) DeleteCNAMERecord(ctx context.Context, domain string) error
- func (c Client) DeleteDNSRecord(ctx context.Context, domain string) error
- func (c Client) DeleteGroup(ctx context.Context, name string) error
- func (c Client) GetAdBlockerStatus(ctx context.Context) (*EnableAdBlock, error)
- func (c Client) GetCNAMERecord(ctx context.Context, domain string) (*CNAMERecord, error)
- func (c Client) GetDNSRecord(ctx context.Context, domain string) (*DNSRecord, error)
- func (c Client) GetGroup(ctx context.Context, name string) (*Group, error)
- func (c Client) GetGroupByID(ctx context.Context, id int64) (*Group, error)
- func (c *Client) Init(ctx context.Context) error
- func (c Client) ListCNAMERecords(ctx context.Context) (CNAMERecordList, error)
- func (c Client) ListDNSRecords(ctx context.Context) (DNSRecordList, error)
- func (c Client) ListDomains(ctx context.Context, opts ListDomainsOptions) (DomainList, error)
- func (c Client) ListGroups(ctx context.Context) (GroupList, error)
- func (c *Client) Login(ctx context.Context) error
- func (c *Client) Request(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
- func (c Client) RequestWithAuth(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
- func (c Client) RequestWithSession(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
- func (c Client) SetAdBlockEnabled(ctx context.Context, enable bool) (*EnableAdBlock, error)
- func (c Client) UpdateGroup(ctx context.Context, gr *GroupUpdateRequest) (*Group, error)
- type Config
- type CreateCNAMERecordResponse
- type CreateDNSRecordResponse
- type DNSRecord
- type DNSRecordList
- type DNSRecordsListResponse
- type Domain
- type DomainList
- type DomainResponse
- type DomainResponseList
- type EnableAdBlock
- type EnableAdBlockResponse
- type Group
- type GroupBasicResponse
- type GroupCreateRequest
- type GroupList
- type GroupResponse
- type GroupResponseList
- type GroupUpdateRequest
- type ListDomainsOptions
- type NotFoundError
Constants ¶
const ( // DomainTypeAllow indicates a domain that is added to the allow list DomainTypeAllowExact int = 0 // DomainTypeDeny indicates a domain that is added to the deny list DomainTypeDenyExact int = 1 // DomainTypeAllowWildcard indicates a wildcard domain added to the allow list DomainTypeAllowWildcard int = 2 // DomainTypeDenyWildcard indicates a wildcard domain added to the deny list DomainTypeDenyWildcard int = 3 )
const ( // DomainOptionsAllow is a filter option corresponding to domains on the allowed list DomainOptionsAllow string = "allow" // DomainOptionsDeny is a filter option corresponding to domains on the deny list DomainOptionsDeny string = "deny" )
Variables ¶
var ( // ErrLoginFailed is returned when a login attempt fails ErrLoginFailed = errors.New("login failed") // ErrClientValidationFailed ErrClientValidationFailed = errors.New("client validation failed") // ErrNotImplementedTokenClient is returned when a particular Pi-hole resource cannot be managed due to missing client configuration ErrNotImplementedTokenClient = errors.New("resource is not implemented for the API token client") )
var IntToDomainType = map[int]string{ DomainTypeAllowExact: DomainOptionsAllow, DomainTypeDenyExact: DomainOptionsDeny, DomainTypeAllowWildcard: DomainOptionsAllow, DomainTypeDenyWildcard: DomainOptionsDeny, }
Functions ¶
Types ¶
type CNAMERecord ¶ added in v0.0.2
type CNAMERecord = pihole.CNAMERecord
type CNAMERecordList ¶ added in v0.0.2
type CNAMERecordList = pihole.CNAMERecordList
type CNAMERecordsListResponse ¶ added in v0.0.2
type CNAMERecordsListResponse struct {
Data [][]string
}
func (CNAMERecordsListResponse) ToCNAMERecordList ¶ added in v0.0.3
func (rr CNAMERecordsListResponse) ToCNAMERecordList() CNAMERecordList
ToCNAMERecordList converts a CNAMERecordsListResponse into a CNAMERecordsList object.
type Client ¶
func (Client) CreateCNAMERecord ¶ added in v0.0.3
func (c Client) CreateCNAMERecord(ctx context.Context, record *CNAMERecord) (*CNAMERecord, error)
CreateCNAMERecord handles CNAME record creation
func (Client) CreateDNSRecord ¶
CreateDNSRecord creates a pihole DNS record entry
func (Client) CreateGroup ¶ added in v0.0.5
CreateGroup creates a group with the passed attributes
func (Client) DeleteCNAMERecord ¶ added in v0.0.3
DeleteCNAMERecord handles CNAME record deletion for the passed domain
func (Client) DeleteDNSRecord ¶
DeleteDNSRecord deletes a pihole local DNS record by domain name
func (Client) DeleteGroup ¶ added in v0.0.5
DeleteGroup deletes a group
func (Client) GetAdBlockerStatus ¶
func (c Client) GetAdBlockerStatus(ctx context.Context) (*EnableAdBlock, error)
GetAdBlockerStatus returns whether pihole ad blocking is enabled or not
func (Client) GetCNAMERecord ¶ added in v0.0.3
GetCNAMERecord returns a CNAMERecord for the passed domain if found
func (Client) GetDNSRecord ¶
GetDNSRecord searches the pihole local DNS records for the passed domain and returns a result if found
func (Client) GetGroupByID ¶ added in v0.0.9
GetGroupByID returns a Pi-hole group by ID
func (*Client) Init ¶
Init sets fields on the client which are a product of pihole network requests or other side effects
func (Client) ListCNAMERecords ¶ added in v0.0.2
func (c Client) ListCNAMERecords(ctx context.Context) (CNAMERecordList, error)
ListCNAMERecords returns a list of the configured CNAME Pi-hole records
func (Client) ListDNSRecords ¶
func (c Client) ListDNSRecords(ctx context.Context) (DNSRecordList, error)
ListDNSRecords Returns the list of custom DNS records configured in pihole
func (Client) ListDomains ¶ added in v0.0.7
func (c Client) ListDomains(ctx context.Context, opts ListDomainsOptions) (DomainList, error)
ListDomains returns a list of domains
func (Client) ListGroups ¶ added in v0.0.4
ListGroups returns the list of gravity DB groups
func (*Client) Login ¶ added in v0.2.0
Login creates a session and sets the proper attributes on the client for session based requests (not api token reqeuests)
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
Request executes a basic unauthenticated http request
func (Client) RequestWithAuth ¶
func (c Client) RequestWithAuth(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
RequestWithAuth adds an auth token to the passed request
func (Client) RequestWithSession ¶
func (c Client) RequestWithSession(ctx context.Context, method string, path string, data *url.Values) (*http.Request, error)
RequestWithSession executes a request with appropriate session authentication
func (Client) SetAdBlockEnabled ¶
SetAdBlockEnabled sets whether pihole ad blocking is enabled or not
func (Client) UpdateGroup ¶ added in v0.0.5
UpdateGroup updates a group resource with the passed attribute
type CreateCNAMERecordResponse ¶ added in v0.0.3
type CreateDNSRecordResponse ¶
type DNSRecordList ¶
type DNSRecordList = pihole.DNSRecordList
type DNSRecordsListResponse ¶
type DNSRecordsListResponse struct {
Data [][]string
}
func (DNSRecordsListResponse) ToDNSRecordList ¶
func (rr DNSRecordsListResponse) ToDNSRecordList() DNSRecordList
ToDNSRecordList converts a DNSRecordsListResponse into a DNSRecordList object.
type DomainList ¶ added in v0.0.7
type DomainList []*Domain
type DomainResponse ¶ added in v0.0.7
type DomainResponse struct { ID int64 `json:"id"` Type int `json:"type"` Enabled int `json:"enabled"` Domain string `json:"domain"` Comment string `json:"comment"` DateAdded int64 `json:"date_added"` DateModified int64 `json:"date_modified"` Groups []int64 `json:"groups"` }
func (DomainResponse) ToDomain ¶ added in v0.0.7
func (d DomainResponse) ToDomain() *Domain
type DomainResponseList ¶ added in v0.0.7
type DomainResponseList struct {
Data []*DomainResponse
}
func (DomainResponseList) ToDomainList ¶ added in v0.0.7
func (l DomainResponseList) ToDomainList() DomainList
type EnableAdBlock ¶
type EnableAdBlock struct {
Enabled bool
}
type EnableAdBlockResponse ¶
type EnableAdBlockResponse struct {
Status string
}
func (EnableAdBlockResponse) ToEnableAdBlock ¶
func (eb EnableAdBlockResponse) ToEnableAdBlock() *EnableAdBlock
ToEnableAdBlock turns am EnableAdBlockResponse into an EnableAdBlock object
type GroupBasicResponse ¶ added in v0.0.5
type GroupCreateRequest ¶ added in v0.0.5
type GroupResponse ¶ added in v0.0.4
type GroupResponse struct { ID int64 `json:"id"` Enabled int `json:"enabled"` Name string `json:"name"` DateAdded int64 `json:"date_added"` DateModified int64 `json:"date_modified"` Description string `json:"description"` }
func (GroupResponse) ToGroup ¶ added in v0.0.4
func (gr GroupResponse) ToGroup() *Group
ToGroup converts a GroupResponse to a Group
type GroupResponseList ¶ added in v0.0.4
type GroupResponseList struct {
Data []GroupResponse
}
func (GroupResponseList) ToGroupList ¶ added in v0.0.4
func (grl GroupResponseList) ToGroupList() GroupList
ToGroup converts a GroupResponseList to a GroupList
type GroupUpdateRequest ¶ added in v0.0.5
type ListDomainsOptions ¶ added in v0.0.7
type ListDomainsOptions struct {
Type string
}
type NotFoundError ¶ added in v0.0.3
type NotFoundError struct {
// contains filtered or unexported fields
}
func NewNotFoundError ¶ added in v0.0.3
func NewNotFoundError(message string) *NotFoundError
New returns a new NotFoundError
func (*NotFoundError) Error ¶ added in v0.0.3
func (e *NotFoundError) Error() string
func (NotFoundError) Is ¶ added in v0.0.3
func (e NotFoundError) Is(target error) bool