Skip to content

Commit 89655f9

Browse files
committed
fix: fix describe domain request
1 parent 40bf331 commit 89655f9

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

pkg/api/api.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ func FindRecord(client *alidns20150109.Client, domainName, rr, typ string) (
2626
*alidns20150109.DescribeDomainRecordsResponseBodyDomainRecordsRecord, error) {
2727

2828
describeDomainRecordsRequest := &alidns20150109.DescribeDomainRecordsRequest{
29-
DomainName: tea.String(domainName),
30-
RRKeyWord: tea.String(rr),
31-
TypeKeyWord: tea.String(typ),
32-
SearchMode: tea.String("EXACT"),
29+
DomainName: tea.String(domainName),
30+
RRKeyWord: tea.String(rr),
31+
Type: tea.String(typ),
3332
}
3433
resp, err := client.DescribeDomainRecords(describeDomainRecordsRequest)
3534
if err != nil {

pkg/api/example/main.go

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@ import (
1010
)
1111

1212
const (
13-
AccessKeyId = "*"
14-
AccessKeySecret = "*"
15-
)
13+
AccessKeyId = ""
14+
AccessKeySecret = ""
1615

17-
func main() {
18-
client, err := api.CreateClient(AccessKeyId, AccessKeySecret)
19-
if err != nil {
20-
panic(err)
21-
}
16+
Domain = "home.c8g.top"
17+
RR = "@"
18+
Type = "AAAA"
19+
)
2220

21+
func Describe(client *alidns20150109.Client) {
2322
describeDomainRecordsRequest := &alidns20150109.DescribeDomainRecordsRequest{
24-
DomainName: tea.String("home.c8g.top"),
25-
RRKeyWord: tea.String("@"),
26-
TypeKeyWord: tea.String("A"),
23+
DomainName: tea.String(Domain),
24+
RRKeyWord: tea.String(RR),
25+
Type: tea.String(Type),
2726
}
2827
resp, err := client.DescribeDomainRecords(describeDomainRecordsRequest)
2928
if err != nil {
@@ -37,3 +36,27 @@ func main() {
3736

3837
fmt.Println("resp", string(respBytes))
3938
}
39+
40+
func Find(client *alidns20150109.Client) {
41+
rec, err := api.FindRecord(client, Domain, RR, Type)
42+
if err != nil {
43+
panic(err)
44+
}
45+
recBytes, err := json.MarshalIndent(rec, "", " ")
46+
if err != nil {
47+
panic(err)
48+
}
49+
50+
fmt.Println("rec", string(recBytes))
51+
}
52+
53+
func main() {
54+
client, err := api.CreateClient(AccessKeyId, AccessKeySecret)
55+
if err != nil {
56+
panic(err)
57+
}
58+
59+
Describe(client)
60+
61+
Find(client)
62+
}

0 commit comments

Comments
 (0)