mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Co-authored-by: Yannik Sembritzki <yannik@sembritzki.org> Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
committed by
GitHub
parent
e5b7870bb6
commit
1073e04577
@@ -22,7 +22,7 @@ type hostingdeProvider struct {
|
||||
|
||||
func (hp *hostingdeProvider) getDomainConfig(domain string) (*domainConfig, error) {
|
||||
params := request{
|
||||
Filter: filter{
|
||||
Filter: &filter{
|
||||
Field: "domainName",
|
||||
Value: domain,
|
||||
},
|
||||
@@ -135,7 +135,7 @@ func (hp *hostingdeProvider) getRecords(domain string) ([]*record, error) {
|
||||
page := uint(1)
|
||||
for {
|
||||
params := request{
|
||||
Filter: filter{
|
||||
Filter: &filter{
|
||||
Field: "ZoneConfigId",
|
||||
Value: zc.ID,
|
||||
},
|
||||
@@ -210,7 +210,7 @@ func (hp *hostingdeProvider) getZoneConfig(domain string) (*zoneConfig, error) {
|
||||
}
|
||||
|
||||
params := request{
|
||||
Filter: filter{
|
||||
Filter: &filter{
|
||||
Field: "ZoneName",
|
||||
Value: t,
|
||||
},
|
||||
@@ -267,3 +267,21 @@ func (hp *hostingdeProvider) get(service, method string, params request) (*respo
|
||||
|
||||
return respData.Response, nil
|
||||
}
|
||||
|
||||
func (hp *hostingdeProvider) getAllZoneConfigs() ([]*zoneConfig, error) {
|
||||
params := request{
|
||||
Limit: 10000,
|
||||
}
|
||||
|
||||
resp, err := hp.get("dns", "zoneConfigsFind", params)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get zones: %w", err)
|
||||
}
|
||||
|
||||
zc := []*zoneConfig{}
|
||||
if err := json.Unmarshal(resp.Data, &zc); err != nil {
|
||||
return nil, fmt.Errorf("could not parse response: %w", err)
|
||||
}
|
||||
|
||||
return zc, nil
|
||||
}
|
||||
|
@@ -222,3 +222,16 @@ func (hp *hostingdeProvider) EnsureDomainExists(domain string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hp *hostingdeProvider) ListZones() ([]string, error) {
|
||||
zcs, err := hp.getAllZoneConfigs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
zones := make([]string, 0, len(zcs))
|
||||
for _, zoneConfig := range zcs {
|
||||
zones = append(zones, zoneConfig.Name)
|
||||
}
|
||||
return zones, nil
|
||||
|
||||
}
|
||||
|
@@ -16,11 +16,11 @@ var (
|
||||
)
|
||||
|
||||
type request struct {
|
||||
AuthToken string `json:"authToken"`
|
||||
OwnerAccountID string `json:"ownerAccountId,omitempty"`
|
||||
Filter filter `json:"filter,omitempty"`
|
||||
Limit uint `json:"limit,omitempty"`
|
||||
Page uint `json:"page,omitempty"`
|
||||
AuthToken string `json:"authToken"`
|
||||
OwnerAccountID string `json:"ownerAccountId,omitempty"`
|
||||
Filter *filter `json:"filter,omitempty"`
|
||||
Limit uint `json:"limit,omitempty"`
|
||||
Page uint `json:"page,omitempty"`
|
||||
|
||||
// Update Zone
|
||||
ZoneConfig *zoneConfig `json:"zoneConfig"`
|
||||
|
Reference in New Issue
Block a user