forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registrar_example_test.go
113 lines (95 loc) · 2.97 KB
/
registrar_example_test.go
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
110
111
112
113
package cloudflare_test
import (
"fmt"
"log"
"time"
cloudflare "github.com/cloudflare/cloudflare-go"
)
var (
createdAndModifiedTimestamp, _ = time.Parse(time.RFC3339, "2018-08-28T17:26:26Z")
expiresAtTimestamp, _ = time.Parse(time.RFC3339, "2019-08-28T23:59:59Z")
expectedRegistrarTransferIn = cloudflare.RegistrarTransferIn{
UnlockDomain: "ok",
DisablePrivacy: "ok",
EnterAuthCode: "needed",
ApproveTransfer: "unknown",
AcceptFoa: "needed",
CanCancelTransfer: true,
}
expectedRegistrarContact = cloudflare.RegistrantContact{
ID: "ea95132c15732412d22c1476fa83f27a",
FirstName: "John",
LastName: "Appleseed",
Organization: "Cloudflare, Inc.",
Address: "123 Sesame St.",
Address2: "Suite 430",
City: "Austin",
State: "TX",
Zip: "12345",
Country: "US",
Phone: "+1 123-123-1234",
Email: "[email protected]",
Fax: "123-867-5309",
}
expectedRegistrarDomain = cloudflare.RegistrarDomain{
ID: "ea95132c15732412d22c1476fa83f27a",
Available: false,
SupportedTLD: true,
CanRegister: false,
TransferIn: expectedRegistrarTransferIn,
CurrentRegistrar: "Cloudflare",
ExpiresAt: expiresAtTimestamp,
RegistryStatuses: "ok,serverTransferProhibited",
Locked: false,
CreatedAt: createdAndModifiedTimestamp,
UpdatedAt: createdAndModifiedTimestamp,
RegistrantContact: expectedRegistrarContact,
}
)
func ExampleAPI_RegistrarDomain() {
api, err := cloudflare.New(apiKey, user)
if err != nil {
log.Fatal(err)
}
domain, err := api.RegistrarDomain("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")
fmt.Printf("%+v\n", domain)
}
func ExampleAPI_RegistrarDomains() {
api, err := cloudflare.New(apiKey, user)
if err != nil {
log.Fatal(err)
}
domains, err := api.RegistrarDomains("01a7362d577a6c3019a474fd6f485823")
fmt.Printf("%+v\n", domains)
}
func ExampleAPI_TransferRegistrarDomain() {
api, err := cloudflare.New(apiKey, user)
if err != nil {
log.Fatal(err)
}
domain, err := api.TransferRegistrarDomain("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")
fmt.Printf("%+v\n", domain)
}
func ExampleAPI_CancelRegistrarDomainTransfer() {
api, err := cloudflare.New(apiKey, user)
if err != nil {
log.Fatal(err)
}
domains, err := api.CancelRegistrarDomainTransfer("01a7362d577a6c3019a474fd6f485823", "cloudflare.com")
fmt.Printf("%+v\n", domains)
}
func ExampleAPI_UpdateRegistrarDomain() {
api, err := cloudflare.New(apiKey, user)
if err != nil {
log.Fatal(err)
}
domain, err := api.UpdateRegistrarDomain(
"01a7362d577a6c3019a474fd6f485823",
"cloudflare.com",
cloudflare.RegistrarDomainConfiguration{
NameServers: []string{"ns1.cloudflare.com", "ns2.cloudflare.com"},
Locked: false,
},
)
fmt.Printf("%+v\n", domain)
}