From 49d217a8837055a38275c7ea742b2e278340375a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 26 Sep 2022 11:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4EdgeDNS=20API=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dnsclients/edgeapi/response_base.go | 21 +++++++++++++++++++ .../edgeapi/response_create_ns_record.go | 11 ++++++++++ .../edgeapi/response_find_all_ns_routes.go | 14 +++++++++++++ .../response_find_ns_domain_with_name.go | 14 +++++++++++++ ...ponse_find_ns_record_with_name_and_type.go | 21 +++++++++++++++++++ .../edgeapi/response_get_api_access_token.go | 12 +++++++++++ .../dnsclients/edgeapi/response_interface.go | 8 +++++++ .../edgeapi/response_list_ns_domains.go | 16 ++++++++++++++ .../edgeapi/response_list_ns_records.go | 21 +++++++++++++++++++ .../dnsclients/edgeapi/response_success.go | 7 +++++++ .../edgeapi/response_update_ns_record.go | 7 +++++++ 11 files changed, 152 insertions(+) create mode 100644 internal/dnsclients/edgeapi/response_base.go create mode 100644 internal/dnsclients/edgeapi/response_create_ns_record.go create mode 100644 internal/dnsclients/edgeapi/response_find_all_ns_routes.go create mode 100644 internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go create mode 100644 internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go create mode 100644 internal/dnsclients/edgeapi/response_get_api_access_token.go create mode 100644 internal/dnsclients/edgeapi/response_interface.go create mode 100644 internal/dnsclients/edgeapi/response_list_ns_domains.go create mode 100644 internal/dnsclients/edgeapi/response_list_ns_records.go create mode 100644 internal/dnsclients/edgeapi/response_success.go create mode 100644 internal/dnsclients/edgeapi/response_update_ns_record.go diff --git a/internal/dnsclients/edgeapi/response_base.go b/internal/dnsclients/edgeapi/response_base.go new file mode 100644 index 00000000..ee3aa5ff --- /dev/null +++ b/internal/dnsclients/edgeapi/response_base.go @@ -0,0 +1,21 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +import ( + "errors" + "github.com/iwind/TeaGo/types" +) + +type BaseResponse struct { + Code int `json:"code"` + Message string `json:"message"` +} + +func (this *BaseResponse) IsValid() bool { + return this.Code == 200 +} + +func (this *BaseResponse) Error() error { + return errors.New("code: " + types.String(this.Code) + ", message: " + this.Message) +} diff --git a/internal/dnsclients/edgeapi/response_create_ns_record.go b/internal/dnsclients/edgeapi/response_create_ns_record.go new file mode 100644 index 00000000..2e5f4490 --- /dev/null +++ b/internal/dnsclients/edgeapi/response_create_ns_record.go @@ -0,0 +1,11 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type CreateNSRecordResponse struct { + BaseResponse + + Data struct { + NSRecordId int64 `json:"nsRecordId"` + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_find_all_ns_routes.go b/internal/dnsclients/edgeapi/response_find_all_ns_routes.go new file mode 100644 index 00000000..dcf25296 --- /dev/null +++ b/internal/dnsclients/edgeapi/response_find_all_ns_routes.go @@ -0,0 +1,14 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type FindAllNSRoutesResponse struct { + BaseResponse + + Data struct { + NSRoutes []struct { + Name string `json:"name"` + Code string `json:"code"` + } `json:"nsRoutes"` + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go b/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go new file mode 100644 index 00000000..82533e26 --- /dev/null +++ b/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go @@ -0,0 +1,14 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type FindDomainWithNameResponse struct { + BaseResponse + + Data struct { + NSDomain struct { + Id int64 `json:"id"` + Name string `json:"name"` + } + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go b/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go new file mode 100644 index 00000000..b57adb4e --- /dev/null +++ b/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go @@ -0,0 +1,21 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type FindNSRecordWithNameAndTypeResponse struct { + BaseResponse + + Data struct { + NSRecord struct { + Id int64 `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Value string `json:"value"` + TTL int32 `json:"ttl"` + NSRoutes []struct { + Name string `json:"name"` + Code string `json:"code"` + } `json:"nsRoutes"` + } `json:"nsRecord"` + } +} diff --git a/internal/dnsclients/edgeapi/response_get_api_access_token.go b/internal/dnsclients/edgeapi/response_get_api_access_token.go new file mode 100644 index 00000000..a165695b --- /dev/null +++ b/internal/dnsclients/edgeapi/response_get_api_access_token.go @@ -0,0 +1,12 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type GetAPIAccessToken struct { + BaseResponse + + Data struct { + Token string `json:"token"` + ExpiresAt int64 `json:"expiresAt"` + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_interface.go b/internal/dnsclients/edgeapi/response_interface.go new file mode 100644 index 00000000..b888c57e --- /dev/null +++ b/internal/dnsclients/edgeapi/response_interface.go @@ -0,0 +1,8 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type ResponseInterface interface { + IsValid() bool + Error() error +} diff --git a/internal/dnsclients/edgeapi/response_list_ns_domains.go b/internal/dnsclients/edgeapi/response_list_ns_domains.go new file mode 100644 index 00000000..3d849800 --- /dev/null +++ b/internal/dnsclients/edgeapi/response_list_ns_domains.go @@ -0,0 +1,16 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type ListNSDomainsResponse struct { + BaseResponse + + Data struct { + NSDomains []struct { + Id int64 `json:"id"` + Name string `json:"name"` + IsOn bool `json:"isOn"` + IsDeleted bool `json:"isDeleted"` + } `json:"nsDomains"` + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_list_ns_records.go b/internal/dnsclients/edgeapi/response_list_ns_records.go new file mode 100644 index 00000000..c1348b3f --- /dev/null +++ b/internal/dnsclients/edgeapi/response_list_ns_records.go @@ -0,0 +1,21 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type ListNSRecordsResponse struct { + BaseResponse + + Data struct { + NSRecords []struct { + Id int64 `json:"id"` + Name string `json:"name"` + Value string `json:"value"` + TTL int32 `json:"ttl"` + Type string `json:"type"` + NSRoutes []struct { + Name string `json:"name"` + Code string `json:"code"` + } `json:"nsRoutes"` + } `json:"nsRecords"` + } `json:"data"` +} diff --git a/internal/dnsclients/edgeapi/response_success.go b/internal/dnsclients/edgeapi/response_success.go new file mode 100644 index 00000000..198b1abd --- /dev/null +++ b/internal/dnsclients/edgeapi/response_success.go @@ -0,0 +1,7 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type SuccessResponse struct { + BaseResponse +} diff --git a/internal/dnsclients/edgeapi/response_update_ns_record.go b/internal/dnsclients/edgeapi/response_update_ns_record.go new file mode 100644 index 00000000..b60af337 --- /dev/null +++ b/internal/dnsclients/edgeapi/response_update_ns_record.go @@ -0,0 +1,7 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package edgeapi + +type UpdateNSRecordResponse struct { + BaseResponse +}