mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8416 from lvyangyang/fix/qcloud_dns_all_project
fix:get all project dns resource
This commit is contained in:
@@ -58,10 +58,14 @@ type SDomian struct {
|
||||
}
|
||||
|
||||
// https://cloud.tencent.com/document/product/302/8505
|
||||
func (client *SQcloudClient) GetDomains(offset int, limit int) ([]SDomian, int, error) {
|
||||
func (client *SQcloudClient) GetDomains(projectId string, offset int, limit int) ([]SDomian, int, error) {
|
||||
params := map[string]string{}
|
||||
params["offset"] = strconv.Itoa(offset)
|
||||
params["length"] = strconv.Itoa(limit)
|
||||
if len(projectId) > 0 {
|
||||
params["qProjectId"] = projectId
|
||||
}
|
||||
|
||||
resp, err := client.cnsRequest("DomainList", params)
|
||||
if err != nil {
|
||||
return nil, 0, errors.Wrapf(err, "client.cnsRequest(DomainList, %s)", jsonutils.Marshal(params).String())
|
||||
@@ -87,7 +91,8 @@ func (client *SQcloudClient) GetAllDomains() ([]SDomian, error) {
|
||||
count := 0
|
||||
result := []SDomian{}
|
||||
for {
|
||||
domains, total, err := client.GetDomains(count, 100)
|
||||
// -1 所有项目; 0,default默认项目
|
||||
domains, total, err := client.GetDomains("-1", count, 100)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, " client.GetDomains(count, 100)")
|
||||
}
|
||||
|
||||
@@ -57,12 +57,15 @@ type SDnsRecord struct {
|
||||
}
|
||||
|
||||
// https://cloud.tencent.com/document/product/302/8517
|
||||
func (client *SQcloudClient) GetDnsRecords(sDomainName string, offset int, limit int) ([]SDnsRecord, int, error) {
|
||||
func (client *SQcloudClient) GetDnsRecords(projectId string, sDomainName string, offset int, limit int) ([]SDnsRecord, int, error) {
|
||||
|
||||
params := map[string]string{}
|
||||
params["offset"] = strconv.Itoa(offset)
|
||||
params["length"] = strconv.Itoa(limit)
|
||||
params["domain"] = sDomainName
|
||||
if len(projectId) > 0 {
|
||||
params["qProjectId"] = projectId
|
||||
}
|
||||
resp, err := client.cnsRequest("RecordList", params)
|
||||
if err != nil {
|
||||
return nil, 0, errors.Wrapf(err, "client.cnsRequest(RecordList, %s)", jsonutils.Marshal(params).String())
|
||||
@@ -88,7 +91,8 @@ func (client *SQcloudClient) GetAllDnsRecords(sDomainName string) ([]SDnsRecord,
|
||||
count := 0
|
||||
result := []SDnsRecord{}
|
||||
for true {
|
||||
records, total, err := client.GetDnsRecords(sDomainName, count, 100)
|
||||
// -1 所有项目; 0,default默认项目
|
||||
records, total, err := client.GetDnsRecords("-1", sDomainName, count, 100)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "client.GetDnsRecords(%s,%d,%d)", sDomainName, count, 100)
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@ import (
|
||||
|
||||
func init() {
|
||||
type DomianListOptions struct {
|
||||
Offset int
|
||||
Limit int
|
||||
Offset int
|
||||
Limit int
|
||||
ProjectId string
|
||||
}
|
||||
shellutils.R(&DomianListOptions{}, "domain-list", "List domains", func(cli *qcloud.SRegion, args *DomianListOptions) error {
|
||||
domains, total, e := cli.GetClient().GetDomains(args.Offset, args.Limit)
|
||||
domains, total, e := cli.GetClient().GetDomains(args.ProjectId, args.Offset, args.Limit)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
@@ -61,12 +62,13 @@ func init() {
|
||||
})
|
||||
|
||||
type DnsRecordListOptions struct {
|
||||
DOMAIN string
|
||||
Offset int
|
||||
Limit int
|
||||
DOMAIN string
|
||||
ProjectId string
|
||||
Offset int
|
||||
Limit int
|
||||
}
|
||||
shellutils.R(&DnsRecordListOptions{}, "dnsrecord-list", "List dndrecord", func(cli *qcloud.SRegion, args *DnsRecordListOptions) error {
|
||||
records, total, e := cli.GetClient().GetDnsRecords(args.DOMAIN, args.Offset, args.Limit)
|
||||
records, total, e := cli.GetClient().GetDnsRecords(args.ProjectId, args.DOMAIN, args.Offset, args.Limit)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
@@ -84,7 +86,7 @@ func init() {
|
||||
}
|
||||
shellutils.R(&DnsRecordCreateOptions{}, "dnsrecord-create", "create dndrecord", func(cli *qcloud.SRegion, args *DnsRecordCreateOptions) error {
|
||||
change := cloudprovider.DnsRecordSet{}
|
||||
change.DnsName = args.DOMAIN
|
||||
change.DnsName = args.NAME
|
||||
change.DnsValue = args.VALUE
|
||||
change.Ttl = args.TTL
|
||||
change.DnsType = cloudprovider.TDnsType(args.TYPE)
|
||||
|
||||
Reference in New Issue
Block a user