File: registrar_domain_transfer_lock.go

package info (click to toggle)
golang-github-dnsimple-dnsimple-go 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,428 kB
  • sloc: makefile: 3
file content (63 lines) | stat: -rw-r--r-- 1,959 bytes parent folder | download
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
package dnsimple

import (
	"context"
	"fmt"
)

type DomainTransferLock struct {
	Enabled bool `json:"enabled"`
}

type DomainTransferLockResponse struct {
	Response
	Data *DomainTransferLock `json:"data"`
}

// GetDomainTransferLock gets the domain transfer lock for a domain.
//
// See https://developer.dnsimple.com/v2/registrar/#getDomainTransferLock
func (s *RegistrarService) GetDomainTransferLock(ctx context.Context, accountID string, domainIdentifier string) (*DomainTransferLockResponse, error) {
	path := versioned(fmt.Sprintf("%v/registrar/domains/%v/transfer_lock", accountID, domainIdentifier))
	res := &DomainTransferLockResponse{}

	httpRes, err := s.client.get(ctx, path, res)
	if err != nil {
		return nil, err
	}

	res.HTTPResponse = httpRes
	return res, nil
}

// EnableDomainTransferLock gets the domain transfer lock for a domain.
//
// See https://developer.dnsimple.com/v2/registrar/#enableDomainTransferLock
func (s *RegistrarService) EnableDomainTransferLock(ctx context.Context, accountID string, domainIdentifier string) (*DomainTransferLockResponse, error) {
	path := versioned(fmt.Sprintf("%v/registrar/domains/%v/transfer_lock", accountID, domainIdentifier))
	res := &DomainTransferLockResponse{}

	httpRes, err := s.client.post(ctx, path, nil, res)
	if err != nil {
		return nil, err
	}

	res.HTTPResponse = httpRes
	return res, nil
}

// DisableDomainTransferLock gets the domain transfer lock for a domain.
//
// See https://developer.dnsimple.com/v2/registrar/#disableDomainTransferLock
func (s *RegistrarService) DisableDomainTransferLock(ctx context.Context, accountID string, domainIdentifier string) (*DomainTransferLockResponse, error) {
	path := versioned(fmt.Sprintf("%v/registrar/domains/%v/transfer_lock", accountID, domainIdentifier))
	res := &DomainTransferLockResponse{}

	httpRes, err := s.client.delete(ctx, path, nil, res)
	if err != nil {
		return nil, err
	}

	res.HTTPResponse = httpRes
	return res, nil
}