1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
package dnsimple
import (
"context"
"fmt"
)
// DelegationSignerRecord represents a delegation signer record for a domain in DNSimple.
type DelegationSignerRecord struct {
ID int64 `json:"id,omitempty"`
DomainID int64 `json:"domain_id,omitempty"`
Algorithm string `json:"algorithm"`
Digest string `json:"digest,omitempty"`
DigestType string `json:"digest_type,omitempty"`
Keytag string `json:"keytag,omitempty"`
PublicKey string `json:"public_key,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
func delegationSignerRecordPath(accountID string, domainIdentifier string, dsRecordID int64) (path string) {
path = fmt.Sprintf("%v/ds_records", domainPath(accountID, domainIdentifier))
if dsRecordID != 0 {
path += fmt.Sprintf("/%v", dsRecordID)
}
return
}
// DelegationSignerRecordResponse represents a response from an API method that returns a DelegationSignerRecord struct.
type DelegationSignerRecordResponse struct {
Response
Data *DelegationSignerRecord `json:"data"`
}
// DelegationSignerRecordsResponse represents a response from an API method that returns a DelegationSignerRecord struct.
type DelegationSignerRecordsResponse struct {
Response
Data []DelegationSignerRecord `json:"data"`
}
// ListDelegationSignerRecords lists the delegation signer records for a domain.
//
// See https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-list
func (s *DomainsService) ListDelegationSignerRecords(ctx context.Context, accountID string, domainIdentifier string, options *ListOptions) (*DelegationSignerRecordsResponse, error) {
path := versioned(delegationSignerRecordPath(accountID, domainIdentifier, 0))
dsRecordsResponse := &DelegationSignerRecordsResponse{}
path, err := addURLQueryOptions(path, options)
if err != nil {
return nil, err
}
resp, err := s.client.get(ctx, path, dsRecordsResponse)
if err != nil {
return nil, err
}
dsRecordsResponse.HTTPResponse = resp
return dsRecordsResponse, nil
}
// CreateDelegationSignerRecord creates a new delegation signer record.
//
// See https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-create
func (s *DomainsService) CreateDelegationSignerRecord(ctx context.Context, accountID string, domainIdentifier string, dsRecordAttributes DelegationSignerRecord) (*DelegationSignerRecordResponse, error) {
path := versioned(delegationSignerRecordPath(accountID, domainIdentifier, 0))
dsRecordResponse := &DelegationSignerRecordResponse{}
resp, err := s.client.post(ctx, path, dsRecordAttributes, dsRecordResponse)
if err != nil {
return nil, err
}
dsRecordResponse.HTTPResponse = resp
return dsRecordResponse, nil
}
// GetDelegationSignerRecord fetches a delegation signer record.
//
// See https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-get
func (s *DomainsService) GetDelegationSignerRecord(ctx context.Context, accountID string, domainIdentifier string, dsRecordID int64) (*DelegationSignerRecordResponse, error) {
path := versioned(delegationSignerRecordPath(accountID, domainIdentifier, dsRecordID))
dsRecordResponse := &DelegationSignerRecordResponse{}
resp, err := s.client.get(ctx, path, dsRecordResponse)
if err != nil {
return nil, err
}
dsRecordResponse.HTTPResponse = resp
return dsRecordResponse, nil
}
// DeleteDelegationSignerRecord PERMANENTLY deletes a delegation signer record
// from the domain.
//
// See https://developer.dnsimple.com/v2/domains/dnssec/#ds-record-delete
func (s *DomainsService) DeleteDelegationSignerRecord(ctx context.Context, accountID string, domainIdentifier string, dsRecordID int64) (*DelegationSignerRecordResponse, error) {
path := versioned(delegationSignerRecordPath(accountID, domainIdentifier, dsRecordID))
dsRecordResponse := &DelegationSignerRecordResponse{}
resp, err := s.client.delete(ctx, path, nil, nil)
if err != nil {
return nil, err
}
dsRecordResponse.HTTPResponse = resp
return dsRecordResponse, nil
}
|