1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

HOSTINGDE: Implement subaccount filtering feature (fixes #1974) (#2025)

Co-authored-by: Yannik Sembritzki <yannik@sembritzki.org>
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Yannik Sembritzki
2023-02-01 00:03:29 +08:00
committed by GitHub
parent 83299e178e
commit 7f16c9ca6d
2 changed files with 17 additions and 9 deletions

View File

@@ -14,10 +14,11 @@ import (
const endpoint = "%s/api/%s/v1/json/%s" const endpoint = "%s/api/%s/v1/json/%s"
type hostingdeProvider struct { type hostingdeProvider struct {
authToken string authToken string
ownerAccountID string ownerAccountID string
baseURL string filterAccountId string
nameservers []string baseURL string
nameservers []string
} }
func (hp *hostingdeProvider) getDomainConfig(domain string) (*domainConfig, error) { func (hp *hostingdeProvider) getDomainConfig(domain string) (*domainConfig, error) {
@@ -285,6 +286,12 @@ func (hp *hostingdeProvider) getAllZoneConfigs() ([]*zoneConfig, error) {
params := request{ params := request{
Limit: 10000, Limit: 10000,
} }
if hp.filterAccountId != "" {
params.Filter = &filter{
Field: "accountId",
Value: hp.filterAccountId,
}
}
resp, err := hp.get("dns", "zoneConfigsFind", params) resp, err := hp.get("dns", "zoneConfigsFind", params)
if err != nil { if err != nil {

View File

@@ -46,7 +46,7 @@ type providerMeta struct {
} }
func newHostingde(m map[string]string, providermeta json.RawMessage) (*hostingdeProvider, error) { func newHostingde(m map[string]string, providermeta json.RawMessage) (*hostingdeProvider, error) {
authToken, ownerAccountID, baseURL := m["authToken"], m["ownerAccountId"], m["baseURL"] authToken, ownerAccountID, filterAccountId, baseURL := m["authToken"], m["ownerAccountId"], m["filterAccountId"], m["baseURL"]
if authToken == "" { if authToken == "" {
return nil, fmt.Errorf("hosting.de: authtoken must be provided") return nil, fmt.Errorf("hosting.de: authtoken must be provided")
@@ -58,10 +58,11 @@ func newHostingde(m map[string]string, providermeta json.RawMessage) (*hostingde
baseURL = strings.TrimSuffix(baseURL, "/") baseURL = strings.TrimSuffix(baseURL, "/")
hp := &hostingdeProvider{ hp := &hostingdeProvider{
authToken: authToken, authToken: authToken,
ownerAccountID: ownerAccountID, ownerAccountID: ownerAccountID,
baseURL: baseURL, filterAccountId: filterAccountId,
nameservers: defaultNameservers, baseURL: baseURL,
nameservers: defaultNameservers,
} }
if len(providermeta) > 0 { if len(providermeta) > 0 {