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 +}