Skip to content

Commit

Permalink
debug: list services
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Nov 21, 2024
1 parent f854bc3 commit 5def332
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions providers/dns/nicru/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ func NewClient(httpClient *http.Client, serviceName string) (*Client, error) {
}, nil
}

func (c *Client) GetServices(ctx context.Context) ([]Service, error) {
endpoint := c.baseURL.JoinPath("services")

req, err := newXMLRequest(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return nil, err
}
apiResponse, err := c.do(req)
if err != nil {
return nil, err
}

if apiResponse.Data == nil {
return nil, nil
}

return apiResponse.Data.Service, nil
}

func (c *Client) GetZones(ctx context.Context) ([]Zone, error) {
endpoint := c.baseURL.JoinPath("services", c.serviceName, "zones")

Expand Down
12 changes: 12 additions & 0 deletions providers/dns/nicru/internal/fixtures/services_GET.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<status>success</status>
<data>
<service admin="123/NIC-REG" domains-limit="12" domains-num="5" enable="true" has-primary="false"
name="testservice"
payer="123/NIC-REG" tariff="Secondary L"/>
<service admin="123/NIC-REG" domains-limit="150" domains-num="10" enable="true" has-primary="true"
name="myservice"
payer="123/NIC-REG" rr-limit="7500" rr-num="1000" tariff="DNS-master XXL"/>
</data>
</response>
9 changes: 9 additions & 0 deletions providers/dns/nicru/nicru.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ func (p *DNSProvider) Present(domain, _, keyAuth string) error {

ctx := context.Background()

services, err := p.client.GetServices(ctx)
if err != nil {
return fmt.Errorf("nicru: get services: %w", err)
}

for _, service := range services {
log.Infof("service.Name=%s, service.Payer=%s, service.DomainsNum=%s, service.DomainsLimit=%s", service.Name, service.Payer, service.DomainsNum, service.DomainsLimit)
}

err = p.checkZoneUUID(ctx, authZone)
if err != nil {
return fmt.Errorf("nicru: %w", err)
Expand Down

0 comments on commit 5def332

Please sign in to comment.