mirror of
				https://github.com/go-acme/lego.git
				synced 2025-10-31 08:27:38 +02:00 
			
		
		
		
	chore: migrate to nrdcg. (#779)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							c4730a6ec3
						
					
				
				
					commit
					3019d10801
				
			| @@ -81,7 +81,7 @@ git push -u origin my-feature | ||||
| |---------------------------|----------------|--------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------| | ||||
| | Acme DNS                  | `acmedns`      | [documentation](https://github.com/joohoi/acme-dns#api)                                                      | [Go client](https://github.com/cpu/goacmedns)                     | | ||||
| | Alibaba Cloud             | `alidns`       | [documentation](https://www.alibabacloud.com/help/doc-detail/42875.htm)                                      | [Go client](https://github.com/aliyun/alibaba-cloud-sdk-go)       | | ||||
| | Aurora DNS                | `auroradns`    | [documentation](https://libcloud.readthedocs.io/en/latest/dns/drivers/auroradns.html#api-docs)               | [Go client](https://github.com/edeckers/auroradnsclient)          | | ||||
| | Aurora DNS                | `auroradns`    | [documentation](https://libcloud.readthedocs.io/en/latest/dns/drivers/auroradns.html#api-docs)               | [Go client](https://github.com/nrdcg/auroradns)          | | ||||
| | Azure                     | `azure`        | [documentation](https://docs.microsoft.com/en-us/go/azure/)                                                  | [Go client](https://github.com/Azure/azure-sdk-for-go)            | | ||||
| | Bluecat                   | `bluecat`      | ?                                                                                                            | -                                                                 | | ||||
| | Cloudflare                | `cloudflare`   | [documentation](https://api.cloudflare.com/)                                                                 | [Go client](https://github.com/cloudflare/cloudflare-go)          | | ||||
| @@ -104,7 +104,7 @@ git push -u origin my-feature | ||||
| | Go Daddy                  | `godaddy`      | [documentation](https://developer.godaddy.com/doc/endpoint/domains)                                          | -                                                                 | | ||||
| | hosting.de                | `hostingde`    | [documentation](https://www.hosting.de/api/#dns)                                                             | -                                                                 | | ||||
| | Internet Initiative Japan | `iij`          | [documentation](http://manual.iij.jp/p2/pubapi/)                                                             | [Go client](https://github.com/iij/doapi)                         | | ||||
| | INWX                      | `inwx`         | [documentation](https://www.inwx.de/en/help/apidoc)                                                          | [Go client](https://github.com/smueller18/goinwx)                 |  | ||||
| | INWX                      | `inwx`         | [documentation](https://www.inwx.de/en/help/apidoc)                                                          | [Go client](https://github.com/nrdcg/goinwx)                 |  | ||||
| | Lightsail                 | `lightsail`    | ?                                                                                                            | [Go client](https://github.com/aws/aws-sdk-go/aws)                | | ||||
| | Linode (deprecated)       | `linode`       | [documentation](https://www.linode.com/api/dns)                                                              | [Go client](https://github.com/timewasted/linode)                 | | ||||
| | Linodev4                  | `linodev4`     | [documentation](https://developers.linode.com/api/v4)                                                        | [Go client](https://github.com/linode/linodego)                   | | ||||
|   | ||||
							
								
								
									
										36
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										36
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							| @@ -281,14 +281,6 @@ | ||||
|   pruneopts = "NUT" | ||||
|   revision = "16bdd962781df9696f40cc2bab924f1a855a7f89" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:417193ba917954c4837c6fc48c6ac241b3fefd13fc0889367b4a7e43b69d582c" | ||||
|   name = "github.com/ldez/go-auroradns" | ||||
|   packages = ["."] | ||||
|   pruneopts = "NUT" | ||||
|   revision = "b40dfcae7c417f8129579362695dc1f3cfe5928d" | ||||
|   version = "v2.0.0" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:111ff5a09a32895248270bfaef9b8b6ac163a8cde9cdd603fed64b3e4b59e8ab" | ||||
|   name = "github.com/linode/linodego" | ||||
| @@ -345,6 +337,22 @@ | ||||
|   pruneopts = "NUT" | ||||
|   revision = "08470befbe04613bd4b44cb6978b05d50294c4d4" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:417193ba917954c4837c6fc48c6ac241b3fefd13fc0889367b4a7e43b69d582c" | ||||
|   name = "github.com/nrdcg/auroradns" | ||||
|   packages = ["."] | ||||
|   pruneopts = "NUT" | ||||
|   revision = "750ca8603f9f2cca2457acb22ea6e44d3f05358c" | ||||
|   version = "v1.0.0" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:78bc7967454f8c2a1257b3fe4ed1d57227fb1dff46fd74d38b91bd0d0cc2620a" | ||||
|   name = "github.com/nrdcg/goinwx" | ||||
|   packages = ["."] | ||||
|   pruneopts = "NUT" | ||||
|   revision = "d8152159450570012552f924a0ae6ab3d8c617e0" | ||||
|   version = "v0.6.0" | ||||
|  | ||||
| [[projects]] | ||||
|   branch = "master" | ||||
|   digest = "1:02584222c11b07d1d61cd76cc73e78cbc72810384a7ea69c543246d60d3335f7" | ||||
| @@ -406,14 +414,6 @@ | ||||
|   revision = "3e01752db0189b9157070a0e1668a620f9a85da2" | ||||
|   version = "v1.0.6" | ||||
|  | ||||
| [[projects]] | ||||
|   branch = "master" | ||||
|   digest = "1:94fcec8ba983a96bb3f123ab9690955baf44d6d32de342f95f5a2f665c70457a" | ||||
|   name = "github.com/smueller18/goinwx" | ||||
|   packages = ["."] | ||||
|   pruneopts = "NUT" | ||||
|   revision = "5d138389109eca96463f44f692408f0d1c731278" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:60a46e2410edbf02b419f833372dd1d24d7aa1b916a990a7370e792fada1eadd" | ||||
|   name = "github.com/stretchr/objx" | ||||
| @@ -656,15 +656,15 @@ | ||||
|     "github.com/exoscale/egoscale", | ||||
|     "github.com/iij/doapi", | ||||
|     "github.com/iij/doapi/protocol", | ||||
|     "github.com/ldez/go-auroradns", | ||||
|     "github.com/linode/linodego", | ||||
|     "github.com/miekg/dns", | ||||
|     "github.com/namedotcom/go/namecom", | ||||
|     "github.com/nrdcg/auroradns", | ||||
|     "github.com/nrdcg/goinwx", | ||||
|     "github.com/ovh/go-ovh/ovh", | ||||
|     "github.com/rainycape/memcache", | ||||
|     "github.com/sacloud/libsacloud/api", | ||||
|     "github.com/sacloud/libsacloud/sacloud", | ||||
|     "github.com/smueller18/goinwx", | ||||
|     "github.com/stretchr/testify/assert", | ||||
|     "github.com/stretchr/testify/mock", | ||||
|     "github.com/stretchr/testify/require", | ||||
|   | ||||
| @@ -54,8 +54,8 @@ | ||||
|   name = "github.com/timewasted/linode" | ||||
|  | ||||
| [[constraint]] | ||||
|   branch = "master" | ||||
|   name = "github.com/smueller18/goinwx" | ||||
|   version = "0.6.0" | ||||
|   name = "github.com/nrdcg/goinwx" | ||||
|  | ||||
| [[constraint]] | ||||
|   version = "0.5.1" | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import ( | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	auroradns "github.com/ldez/go-auroradns" | ||||
| 	"github.com/nrdcg/auroradns" | ||||
| 	"github.com/xenolf/lego/challenge/dns01" | ||||
| 	"github.com/xenolf/lego/platform/config/env" | ||||
| ) | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/smueller18/goinwx" | ||||
| 	"github.com/nrdcg/goinwx" | ||||
| 	"github.com/xenolf/lego/challenge/dns01" | ||||
| 	"github.com/xenolf/lego/log" | ||||
| 	"github.com/xenolf/lego/platform/config/env" | ||||
| @@ -99,7 +99,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { | ||||
| 		Name:    dns01.UnFqdn(fqdn), | ||||
| 		Type:    "TXT", | ||||
| 		Content: value, | ||||
| 		Ttl:     d.config.TTL, | ||||
| 		TTL:     d.config.TTL, | ||||
| 	} | ||||
|  | ||||
| 	_, err = d.client.Nameservers.CreateRecord(request) | ||||
| @@ -150,7 +150,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { | ||||
|  | ||||
| 	var lastErr error | ||||
| 	for _, record := range response.Records { | ||||
| 		err = d.client.Nameservers.DeleteRecord(record.Id) | ||||
| 		err = d.client.Nameservers.DeleteRecord(record.ID) | ||||
| 		if err != nil { | ||||
| 			lastErr = fmt.Errorf("inwx: %v", err) | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										0
									
								
								vendor/github.com/smueller18/goinwx/LICENSE → vendor/github.com/nrdcg/goinwx/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										0
									
								
								vendor/github.com/smueller18/goinwx/LICENSE → vendor/github.com/nrdcg/goinwx/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,44 +7,38 @@ const ( | ||||
| 	methodAccountUnlock = "account.unlock" | ||||
| ) | ||||
| 
 | ||||
| type AccountService interface { | ||||
| 	Login() error | ||||
| 	Logout() error | ||||
| 	Lock() error | ||||
| 	Unlock(tan string) error | ||||
| } | ||||
| // AccountService API access to Account. | ||||
| type AccountService service | ||||
| 
 | ||||
| type AccountServiceOp struct { | ||||
| 	client *Client | ||||
| } | ||||
| 
 | ||||
| var _ AccountService = &AccountServiceOp{} | ||||
| 
 | ||||
| func (s *AccountServiceOp) Login() error { | ||||
| // Login Account login. | ||||
| func (s *AccountService) Login() error { | ||||
| 	req := s.client.NewRequest(methodAccountLogin, map[string]interface{}{ | ||||
| 		"user": s.client.Username, | ||||
| 		"pass": s.client.Password, | ||||
| 		"user": s.client.username, | ||||
| 		"pass": s.client.password, | ||||
| 	}) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *AccountServiceOp) Logout() error { | ||||
| // Logout Account logout. | ||||
| func (s *AccountService) Logout() error { | ||||
| 	req := s.client.NewRequest(methodAccountLogout, nil) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *AccountServiceOp) Lock() error { | ||||
| // Lock Account lock. | ||||
| func (s *AccountService) Lock() error { | ||||
| 	req := s.client.NewRequest(methodAccountLock, nil) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *AccountServiceOp) Unlock(tan string) error { | ||||
| // Unlock Account unlock. | ||||
| func (s *AccountService) Unlock(tan string) error { | ||||
| 	req := s.client.NewRequest(methodAccountUnlock, map[string]interface{}{ | ||||
| 		"tan": tan, | ||||
| 	}) | ||||
							
								
								
									
										126
									
								
								vendor/github.com/smueller18/goinwx/contact.go → vendor/github.com/nrdcg/goinwx/contact.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										126
									
								
								vendor/github.com/smueller18/goinwx/contact.go → vendor/github.com/nrdcg/goinwx/contact.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -13,64 +13,11 @@ const ( | ||||
| 	methodContactUpdate = "contact.update" | ||||
| ) | ||||
| 
 | ||||
| type ContactService interface { | ||||
| 	Create(*ContactCreateRequest) (int, error) | ||||
| 	Update(*ContactUpdateRequest) error | ||||
| 	Delete(int) error | ||||
| 	Info(int) (*ContactInfoResponse, error) | ||||
| 	List(string) (*ContactListResponse, error) | ||||
| } | ||||
| // ContactService API access to Contact. | ||||
| type ContactService service | ||||
| 
 | ||||
| type ContactServiceOp struct { | ||||
| 	client *Client | ||||
| } | ||||
| 
 | ||||
| var _ ContactService = &ContactServiceOp{} | ||||
| 
 | ||||
| type ContactCreateRequest struct { | ||||
| 	Type          string `structs:"type"` | ||||
| 	Name          string `structs:"name"` | ||||
| 	Org           string `structs:"org,omitempty"` | ||||
| 	Street        string `structs:"street"` | ||||
| 	City          string `structs:"city"` | ||||
| 	PostalCode    string `structs:"pc"` | ||||
| 	StateProvince string `structs:"sp,omitempty"` | ||||
| 	CountryCode   string `structs:"cc"` | ||||
| 	Voice         string `structs:"voice"` | ||||
| 	Fax           string `structs:"fax,omitempty"` | ||||
| 	Email         string `structs:"email"` | ||||
| 	Remarks       string `structs:"remarks,omitempty"` | ||||
| 	Protection    bool   `structs:"protection,omitempty"` | ||||
| 	Testing       bool   `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type ContactUpdateRequest struct { | ||||
| 	Id            int    `structs:"id"` | ||||
| 	Name          string `structs:"name,omitempty"` | ||||
| 	Org           string `structs:"org,omitempty"` | ||||
| 	Street        string `structs:"street,omitempty"` | ||||
| 	City          string `structs:"city,omitempty"` | ||||
| 	PostalCode    string `structs:"pc,omitempty"` | ||||
| 	StateProvince string `structs:"sp,omitempty"` | ||||
| 	CountryCode   string `structs:"cc,omitempty"` | ||||
| 	Voice         string `structs:"voice,omitempty"` | ||||
| 	Fax           string `structs:"fax,omitempty"` | ||||
| 	Email         string `structs:"email,omitempty"` | ||||
| 	Remarks       string `structs:"remarks,omitempty"` | ||||
| 	Protection    bool   `structs:"protection,omitempty"` | ||||
| 	Testing       bool   `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type ContactInfoResponse struct { | ||||
| 	Contact Contact `mapstructure:"contact"` | ||||
| } | ||||
| 
 | ||||
| type ContactListResponse struct { | ||||
| 	Count    int | ||||
| 	Contacts []Contact `mapstructure:"contact"` | ||||
| } | ||||
| 
 | ||||
| func (s *ContactServiceOp) Create(request *ContactCreateRequest) (int, error) { | ||||
| // Create Creates a contact. | ||||
| func (s *ContactService) Create(request *ContactCreateRequest) (int, error) { | ||||
| 	req := s.client.NewRequest(methodContactCreate, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| @@ -87,28 +34,31 @@ func (s *ContactServiceOp) Create(request *ContactCreateRequest) (int, error) { | ||||
| 	return result["id"], nil | ||||
| } | ||||
| 
 | ||||
| func (s *ContactServiceOp) Delete(roId int) error { | ||||
| // Delete Deletes a contact. | ||||
| func (s *ContactService) Delete(roID int) error { | ||||
| 	req := s.client.NewRequest(methodContactDelete, map[string]interface{}{ | ||||
| 		"id": roId, | ||||
| 		"id": roID, | ||||
| 	}) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *ContactServiceOp) Update(request *ContactUpdateRequest) error { | ||||
| // Update Updates a contact. | ||||
| func (s *ContactService) Update(request *ContactUpdateRequest) error { | ||||
| 	req := s.client.NewRequest(methodContactUpdate, structs.Map(request)) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *ContactServiceOp) Info(contactId int) (*ContactInfoResponse, error) { | ||||
| // Info Get information about a contact. | ||||
| func (s *ContactService) Info(contactID int) (*ContactInfoResponse, error) { | ||||
| 	var requestMap = make(map[string]interface{}) | ||||
| 	requestMap["wide"] = 1 | ||||
| 
 | ||||
| 	if contactId != 0 { | ||||
| 		requestMap["id"] = contactId | ||||
| 	if contactID != 0 { | ||||
| 		requestMap["id"] = contactID | ||||
| 	} | ||||
| 
 | ||||
| 	req := s.client.NewRequest(methodContactInfo, requestMap) | ||||
| @@ -127,7 +77,8 @@ func (s *ContactServiceOp) Info(contactId int) (*ContactInfoResponse, error) { | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *ContactServiceOp) List(search string) (*ContactListResponse, error) { | ||||
| // List Search contacts. | ||||
| func (s *ContactService) List(search string) (*ContactListResponse, error) { | ||||
| 	var requestMap = make(map[string]interface{}) | ||||
| 
 | ||||
| 	if search != "" { | ||||
| @@ -148,3 +99,50 @@ func (s *ContactServiceOp) List(search string) (*ContactListResponse, error) { | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| // ContactCreateRequest API model. | ||||
| type ContactCreateRequest struct { | ||||
| 	Type          string `structs:"type"` | ||||
| 	Name          string `structs:"name"` | ||||
| 	Org           string `structs:"org,omitempty"` | ||||
| 	Street        string `structs:"street"` | ||||
| 	City          string `structs:"city"` | ||||
| 	PostalCode    string `structs:"pc"` | ||||
| 	StateProvince string `structs:"sp,omitempty"` | ||||
| 	CountryCode   string `structs:"cc"` | ||||
| 	Voice         string `structs:"voice"` | ||||
| 	Fax           string `structs:"fax,omitempty"` | ||||
| 	Email         string `structs:"email"` | ||||
| 	Remarks       string `structs:"remarks,omitempty"` | ||||
| 	Protection    bool   `structs:"protection,omitempty"` | ||||
| 	Testing       bool   `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // ContactUpdateRequest API model. | ||||
| type ContactUpdateRequest struct { | ||||
| 	ID            int    `structs:"id"` | ||||
| 	Name          string `structs:"name,omitempty"` | ||||
| 	Org           string `structs:"org,omitempty"` | ||||
| 	Street        string `structs:"street,omitempty"` | ||||
| 	City          string `structs:"city,omitempty"` | ||||
| 	PostalCode    string `structs:"pc,omitempty"` | ||||
| 	StateProvince string `structs:"sp,omitempty"` | ||||
| 	CountryCode   string `structs:"cc,omitempty"` | ||||
| 	Voice         string `structs:"voice,omitempty"` | ||||
| 	Fax           string `structs:"fax,omitempty"` | ||||
| 	Email         string `structs:"email,omitempty"` | ||||
| 	Remarks       string `structs:"remarks,omitempty"` | ||||
| 	Protection    bool   `structs:"protection,omitempty"` | ||||
| 	Testing       bool   `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // ContactInfoResponse API model. | ||||
| type ContactInfoResponse struct { | ||||
| 	Contact Contact `mapstructure:"contact"` | ||||
| } | ||||
| 
 | ||||
| // ContactListResponse API model. | ||||
| type ContactListResponse struct { | ||||
| 	Count    int | ||||
| 	Contacts []Contact `mapstructure:"contact"` | ||||
| } | ||||
							
								
								
									
										328
									
								
								vendor/github.com/smueller18/goinwx/domain.go → vendor/github.com/nrdcg/goinwx/domain.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										328
									
								
								vendor/github.com/smueller18/goinwx/domain.go → vendor/github.com/nrdcg/goinwx/domain.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,25 +29,154 @@ const ( | ||||
| 	methodDomainWhois       = "domain.whois" | ||||
| ) | ||||
| 
 | ||||
| type DomainService interface { | ||||
| 	Check(domains []string) ([]DomainCheckResponse, error) | ||||
| 	Register(request *DomainRegisterRequest) (*DomainRegisterResponse, error) | ||||
| 	Delete(domain string, scheduledDate time.Time) error | ||||
| 	Info(domain string, roId int) (*DomainInfoResponse, error) | ||||
| 	GetPrices(tlds []string) ([]DomainPriceResponse, error) | ||||
| 	List(*DomainListRequest) (*DomainList, error) | ||||
| 	Whois(domain string) (string, error) | ||||
| // DomainService API access to Domain. | ||||
| type DomainService service | ||||
| 
 | ||||
| // Check Checks domains. | ||||
| func (s *DomainService) Check(domains []string) ([]DomainCheckResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainCheck, map[string]interface{}{ | ||||
| 		"domain": domains, | ||||
| 		"wide":   "2", | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	root := new(domainCheckResponseRoot) | ||||
| 	err = mapstructure.Decode(*resp, &root) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return root.Domains, nil | ||||
| } | ||||
| 
 | ||||
| type DomainServiceOp struct { | ||||
| 	client *Client | ||||
| // GetPrices Gets TLDS prices. | ||||
| func (s *DomainService) GetPrices(tlds []string) ([]DomainPriceResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainGetPrices, map[string]interface{}{ | ||||
| 		"tld": tlds, | ||||
| 		"vat": false, | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	root := new(domainPriceResponseRoot) | ||||
| 	err = mapstructure.Decode(*resp, &root) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return root.Prices, nil | ||||
| } | ||||
| 
 | ||||
| var _ DomainService = &DomainServiceOp{} | ||||
| // Register Register a domain. | ||||
| func (s *DomainService) Register(request *DomainRegisterRequest) (*DomainRegisterResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainCreate, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainRegisterResponse | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| // Delete Deletes a domain. | ||||
| func (s *DomainService) Delete(domain string, scheduledDate time.Time) error { | ||||
| 	req := s.client.NewRequest(methodDomainDelete, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 		"scDate": scheduledDate.Format(time.RFC3339), | ||||
| 	}) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| // Info Gets information about a domain. | ||||
| func (s *DomainService) Info(domain string, roID int) (*DomainInfoResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainInfo, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 		"wide":   "2", | ||||
| 	}) | ||||
| 	if roID != 0 { | ||||
| 		req.Args["roId"] = roID | ||||
| 	} | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainInfoResponse | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	fmt.Println("Response", result) | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| // List List domains. | ||||
| func (s *DomainService) List(request *DomainListRequest) (*DomainList, error) { | ||||
| 	if request == nil { | ||||
| 		return nil, errors.New("request can't be nil") | ||||
| 	} | ||||
| 	requestMap := structs.Map(request) | ||||
| 	requestMap["wide"] = "2" | ||||
| 
 | ||||
| 	req := s.client.NewRequest(methodDomainList, requestMap) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainList | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| // Whois Whois about a domains. | ||||
| func (s *DomainService) Whois(domain string) (string, error) { | ||||
| 	req := s.client.NewRequest(methodDomainWhois, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	var result map[string]string | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	return result["whois"], nil | ||||
| } | ||||
| 
 | ||||
| type domainCheckResponseRoot struct { | ||||
| 	Domains []DomainCheckResponse `mapstructure:"domain"` | ||||
| } | ||||
| 
 | ||||
| // DomainCheckResponse API model. | ||||
| type DomainCheckResponse struct { | ||||
| 	Available   int     `mapstructure:"avail"` | ||||
| 	Status      string  `mapstructure:"status"` | ||||
| @@ -62,6 +191,8 @@ type DomainCheckResponse struct { | ||||
| type domainPriceResponseRoot struct { | ||||
| 	Prices []DomainPriceResponse `mapstructure:"price"` | ||||
| } | ||||
| 
 | ||||
| // DomainPriceResponse API model. | ||||
| type DomainPriceResponse struct { | ||||
| 	Tld                 string  `mapstructure:"tld"` | ||||
| 	Currency            string  `mapstructure:"currency"` | ||||
| @@ -80,6 +211,7 @@ type DomainPriceResponse struct { | ||||
| 	TradePeriod         int     `mapstructure:"tradePeriod"` | ||||
| } | ||||
| 
 | ||||
| // DomainRegisterRequest API model. | ||||
| type DomainRegisterRequest struct { | ||||
| 	Domain        string   `structs:"domain"` | ||||
| 	Period        string   `structs:"period,omitempty"` | ||||
| @@ -91,7 +223,7 @@ type DomainRegisterRequest struct { | ||||
| 	TransferLock  string   `structs:"transferLock,omitempty"` | ||||
| 	RenewalMode   string   `structs:"renewalMode,omitempty"` | ||||
| 	WhoisProvider string   `structs:"whoisProvider,omitempty"` | ||||
| 	WhoisUrl      string   `structs:"whoisUrl,omitempty"` | ||||
| 	WhoisURL      string   `structs:"whoisUrl,omitempty"` | ||||
| 	ScDate        string   `structs:"scDate,omitempty"` | ||||
| 	ExtDate       string   `structs:"extDate,omitempty"` | ||||
| 	Asynchron     string   `structs:"asynchron,omitempty"` | ||||
| @@ -99,14 +231,16 @@ type DomainRegisterRequest struct { | ||||
| 	Testing       string   `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // DomainRegisterResponse API model. | ||||
| type DomainRegisterResponse struct { | ||||
| 	RoId     int | ||||
| 	Price    float32 | ||||
| 	Currency string | ||||
| 	RoID     int     `mapstructure:"roId"` | ||||
| 	Price    float32 `mapstructure:"price"` | ||||
| 	Currency string  `mapstructure:"currency"` | ||||
| } | ||||
| 
 | ||||
| // DomainInfoResponse API model. | ||||
| type DomainInfoResponse struct { | ||||
| 	RoId         int                `mapstructure:"roId"` | ||||
| 	RoID         int                `mapstructure:"roId"` | ||||
| 	Domain       string             `mapstructure:"domain"` | ||||
| 	DomainAce    string             `mapstructure:"domainAce"` | ||||
| 	Period       string             `mapstructure:"period"` | ||||
| @@ -129,27 +263,29 @@ type DomainInfoResponse struct { | ||||
| 	Contacts     map[string]Contact `mapstructure:"contact"` | ||||
| } | ||||
| 
 | ||||
| // Contact API model. | ||||
| type Contact struct { | ||||
| 	RoId          int | ||||
| 	Id            string | ||||
| 	Type          string | ||||
| 	Name          string | ||||
| 	Org           string | ||||
| 	Street        string | ||||
| 	City          string | ||||
| 	RoID          int    `mapstructure:"roId"` | ||||
| 	ID            string `mapstructure:"id"` | ||||
| 	Type          string `mapstructure:"type"` | ||||
| 	Name          string `mapstructure:"name"` | ||||
| 	Org           string `mapstructure:"org"` | ||||
| 	Street        string `mapstructure:"street"` | ||||
| 	City          string `mapstructure:"city"` | ||||
| 	PostalCode    string `mapstructure:"pc"` | ||||
| 	StateProvince string `mapstructure:"sp"` | ||||
| 	Country       string `mapstructure:"cc"` | ||||
| 	Phone         string `mapstructure:"voice"` | ||||
| 	Fax           string | ||||
| 	Email         string | ||||
| 	Remarks       string | ||||
| 	Protection    string | ||||
| 	Fax           string `mapstructure:"fax"` | ||||
| 	Email         string `mapstructure:"email"` | ||||
| 	Remarks       string `mapstructure:"remarks"` | ||||
| 	Protection    string `mapstructure:"protection"` | ||||
| } | ||||
| 
 | ||||
| // DomainListRequest API model. | ||||
| type DomainListRequest struct { | ||||
| 	Domain       string `structs:"domain,omitempty"` | ||||
| 	RoId         int    `structs:"roId,omitempty"` | ||||
| 	RoID         int    `structs:"roId,omitempty"` | ||||
| 	Status       int    `structs:"status,omitempty"` | ||||
| 	Registrant   int    `structs:"registrant,omitempty"` | ||||
| 	Admin        int    `structs:"admin,omitempty"` | ||||
| @@ -161,143 +297,11 @@ type DomainListRequest struct { | ||||
| 	Tag          int    `structs:"tag,omitempty"` | ||||
| 	Order        int    `structs:"order,omitempty"` | ||||
| 	Page         int    `structs:"page,omitempty"` | ||||
| 	Pagelimit    int    `structs:"pagelimit,omitempty"` | ||||
| 	PageLimit    int    `structs:"pagelimit,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // DomainList API model. | ||||
| type DomainList struct { | ||||
| 	Count   int | ||||
| 	Domains []DomainInfoResponse `mapstructure:"domain"` | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) Check(domains []string) ([]DomainCheckResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainCheck, map[string]interface{}{ | ||||
| 		"domain": domains, | ||||
| 		"wide":   "2", | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	root := new(domainCheckResponseRoot) | ||||
| 	err = mapstructure.Decode(*resp, &root) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return root.Domains, nil | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) GetPrices(tlds []string) ([]DomainPriceResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainGetPrices, map[string]interface{}{ | ||||
| 		"tld": tlds, | ||||
| 		"vat": false, | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	root := new(domainPriceResponseRoot) | ||||
| 	err = mapstructure.Decode(*resp, &root) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return root.Prices, nil | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) Register(request *DomainRegisterRequest) (*DomainRegisterResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainCreate, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainRegisterResponse | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) Delete(domain string, scheduledDate time.Time) error { | ||||
| 	req := s.client.NewRequest(methodDomainDelete, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 		"scDate": scheduledDate.Format(time.RFC3339), | ||||
| 	}) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| 	return err | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) Info(domain string, roId int) (*DomainInfoResponse, error) { | ||||
| 	req := s.client.NewRequest(methodDomainInfo, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 		"wide":   "2", | ||||
| 	}) | ||||
| 	if roId != 0 { | ||||
| 		req.Args["roId"] = roId | ||||
| 	} | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainInfoResponse | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	fmt.Println("Response", result) | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) List(request *DomainListRequest) (*DomainList, error) { | ||||
| 	if request == nil { | ||||
| 		return nil, errors.New("Request can't be nil") | ||||
| 	} | ||||
| 	requestMap := structs.Map(request) | ||||
| 	requestMap["wide"] = "2" | ||||
| 
 | ||||
| 	req := s.client.NewRequest(methodDomainList, requestMap) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	var result DomainList | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *DomainServiceOp) Whois(domain string) (string, error) { | ||||
| 	req := s.client.NewRequest(methodDomainWhois, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 	}) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	var result map[string]string | ||||
| 	err = mapstructure.Decode(*resp, &result) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	return result["whois"], nil | ||||
| } | ||||
							
								
								
									
										112
									
								
								vendor/github.com/nrdcg/goinwx/goinwx.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								vendor/github.com/nrdcg/goinwx/goinwx.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,112 @@ | ||||
| package goinwx | ||||
|  | ||||
| import ( | ||||
| 	"net/url" | ||||
|  | ||||
| 	"github.com/kolo/xmlrpc" | ||||
| ) | ||||
|  | ||||
| // API information. | ||||
| const ( | ||||
| 	APIBaseURL        = "https://api.domrobot.com/xmlrpc/" | ||||
| 	APISandboxBaseURL = "https://api.ote.domrobot.com/xmlrpc/" | ||||
| 	APILanguage       = "eng" | ||||
| ) | ||||
|  | ||||
| // Client manages communication with INWX API. | ||||
| type Client struct { | ||||
| 	// HTTP client used to communicate with the INWX API. | ||||
| 	RPCClient *xmlrpc.Client | ||||
|  | ||||
| 	// Base URL for API requests. | ||||
| 	BaseURL *url.URL | ||||
|  | ||||
| 	// API username and password | ||||
| 	username string | ||||
| 	password string | ||||
|  | ||||
| 	common service // Reuse a single struct instead of allocating one for each service on the heap. | ||||
|  | ||||
| 	// Services used for communicating with the API | ||||
| 	Account     *AccountService | ||||
| 	Domains     *DomainService | ||||
| 	Nameservers *NameserverService | ||||
| 	Contacts    *ContactService | ||||
| } | ||||
|  | ||||
| type service struct { | ||||
| 	client *Client | ||||
| } | ||||
|  | ||||
| // ClientOptions Options of the API client. | ||||
| type ClientOptions struct { | ||||
| 	Sandbox bool | ||||
| } | ||||
|  | ||||
| // Request The representation of an API request. | ||||
| type Request struct { | ||||
| 	ServiceMethod string | ||||
| 	Args          map[string]interface{} | ||||
| } | ||||
|  | ||||
| // NewClient returns a new INWX API client. | ||||
| func NewClient(username, password string, opts *ClientOptions) *Client { | ||||
| 	var useSandbox bool | ||||
| 	if opts != nil { | ||||
| 		useSandbox = opts.Sandbox | ||||
| 	} | ||||
|  | ||||
| 	var baseURL *url.URL | ||||
|  | ||||
| 	if useSandbox { | ||||
| 		baseURL, _ = url.Parse(APISandboxBaseURL) | ||||
| 	} else { | ||||
| 		baseURL, _ = url.Parse(APIBaseURL) | ||||
| 	} | ||||
|  | ||||
| 	rpcClient, _ := xmlrpc.NewClient(baseURL.String(), nil) | ||||
|  | ||||
| 	client := &Client{ | ||||
| 		RPCClient: rpcClient, | ||||
| 		BaseURL:   baseURL, | ||||
| 		username:  username, | ||||
| 		password:  password, | ||||
| 	} | ||||
|  | ||||
| 	client.common.client = client | ||||
| 	client.Account = (*AccountService)(&client.common) | ||||
| 	client.Domains = (*DomainService)(&client.common) | ||||
| 	client.Nameservers = (*NameserverService)(&client.common) | ||||
| 	client.Contacts = (*ContactService)(&client.common) | ||||
|  | ||||
| 	return client | ||||
| } | ||||
|  | ||||
| // NewRequest creates an API request. | ||||
| func (c *Client) NewRequest(serviceMethod string, args map[string]interface{}) *Request { | ||||
| 	if args != nil { | ||||
| 		args["lang"] = APILanguage | ||||
| 	} | ||||
|  | ||||
| 	return &Request{ServiceMethod: serviceMethod, Args: args} | ||||
| } | ||||
|  | ||||
| // Do sends an API request and returns the API response. | ||||
| func (c *Client) Do(req Request) (*map[string]interface{}, error) { | ||||
| 	var resp Response | ||||
| 	err := c.RPCClient.Call(req.ServiceMethod, req.Args, &resp) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	return &resp.ResponseData, checkResponse(&resp) | ||||
| } | ||||
|  | ||||
| // checkResponse checks the API response for errors, and returns them if present. | ||||
| func checkResponse(r *Response) error { | ||||
| 	if c := r.Code; c >= 1000 && c <= 1500 { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	return &ErrorResponse{Code: r.Code, Message: r.Message, Reason: r.Reason, ReasonCode: r.ReasonCode} | ||||
| } | ||||
| @@ -21,114 +21,11 @@ const ( | ||||
| 	methodNameserverUpdateRecord = "nameserver.updateRecord" | ||||
| ) | ||||
| 
 | ||||
| type NameserverService interface { | ||||
| 	Check(domain string, nameservers []string) (*NameserverCheckResponse, error) | ||||
| 	Create(*NameserverCreateRequest) (int, error) | ||||
| 	Info(*NameserverInfoRequest) (*NamserverInfoResponse, error) | ||||
| 	List(domain string) (*NamserverListResponse, error) | ||||
| 	CreateRecord(*NameserverRecordRequest) (int, error) | ||||
| 	UpdateRecord(recId int, request *NameserverRecordRequest) error | ||||
| 	DeleteRecord(recId int) error | ||||
| 	FindRecordById(recId int) (*NameserverRecord, *NameserverDomain, error) | ||||
| } | ||||
| // NameserverService API access to Nameservers. | ||||
| type NameserverService service | ||||
| 
 | ||||
| type NameserverServiceOp struct { | ||||
| 	client *Client | ||||
| } | ||||
| 
 | ||||
| var _ NameserverService = &NameserverServiceOp{} | ||||
| 
 | ||||
| type NameserverCheckResponse struct { | ||||
| 	Details []string | ||||
| 	Status  string | ||||
| } | ||||
| 
 | ||||
| type NameserverRecordRequest struct { | ||||
| 	RoId                   int    `structs:"roId,omitempty"` | ||||
| 	Domain                 string `structs:"domain,omitempty"` | ||||
| 	Type                   string `structs:"type"` | ||||
| 	Content                string `structs:"content"` | ||||
| 	Name                   string `structs:"name,omitempty"` | ||||
| 	Ttl                    int    `structs:"ttl,omitempty"` | ||||
| 	Priority               int    `structs:"prio,omitempty"` | ||||
| 	UrlRedirectType        string `structs:"urlRedirectType,omitempty"` | ||||
| 	UrlRedirectTitle       string `structs:"urlRedirectTitle,omitempty"` | ||||
| 	UrlRedirectDescription string `structs:"urlRedirectDescription,omitempty"` | ||||
| 	UrlRedirectFavIcon     string `structs:"urlRedirectFavIcon,omitempty"` | ||||
| 	UrlRedirectKeywords    string `structs:"urlRedirectKeywords,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type NameserverCreateRequest struct { | ||||
| 	Domain                 string   `structs:"domain"` | ||||
| 	Type                   string   `structs:"type"` | ||||
| 	Nameservers            []string `structs:"ns,omitempty"` | ||||
| 	MasterIp               string   `structs:"masterIp,omitempty"` | ||||
| 	Web                    string   `structs:"web,omitempty"` | ||||
| 	Mail                   string   `structs:"mail,omitempty"` | ||||
| 	SoaEmail               string   `structs:"soaEmail,omitempty"` | ||||
| 	UrlRedirectType        string   `structs:"urlRedirectType,omitempty"` | ||||
| 	UrlRedirectTitle       string   `structs:"urlRedirectTitle,omitempty"` | ||||
| 	UrlRedirectDescription string   `structs:"urlRedirectDescription,omitempty"` | ||||
| 	UrlRedirectFavIcon     string   `structs:"urlRedirectFavIcon,omitempty"` | ||||
| 	UrlRedirectKeywords    string   `structs:"urlRedirectKeywords,omitempty"` | ||||
| 	Testing                bool     `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type NameserverInfoRequest struct { | ||||
| 	Domain   string `structs:"domain,omitempty"` | ||||
| 	RoId     int    `structs:"roId,omitempty"` | ||||
| 	RecordId int    `structs:"recordId,omitempty"` | ||||
| 	Type     string `structs:"type,omitempty"` | ||||
| 	Name     string `structs:"name,omitempty"` | ||||
| 	Content  string `structs:"content,omitempty"` | ||||
| 	Ttl      int    `structs:"ttl,omitempty"` | ||||
| 	Prio     int    `structs:"prio,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type NamserverInfoResponse struct { | ||||
| 	RoId          int | ||||
| 	Domain        string | ||||
| 	Type          string | ||||
| 	MasterIp      string | ||||
| 	LastZoneCheck time.Time | ||||
| 	SlaveDns      interface{} | ||||
| 	SOAserial     string | ||||
| 	Count         int | ||||
| 	Records       []NameserverRecord `mapstructure:"record"` | ||||
| } | ||||
| 
 | ||||
| type NameserverRecord struct { | ||||
| 	Id                     int | ||||
| 	Name                   string | ||||
| 	Type                   string | ||||
| 	Content                string | ||||
| 	Ttl                    int | ||||
| 	Prio                   int | ||||
| 	UrlRedirectType        string | ||||
| 	UrlRedirectTitle       string | ||||
| 	UrlRedirectDescription string | ||||
| 	UrlRedirectKeywords    string | ||||
| 	UrlRedirectFavIcon     string | ||||
| } | ||||
| 
 | ||||
| type NamserverListResponse struct { | ||||
| 	Count   int | ||||
| 	Domains []NameserverDomain `mapstructure:"domains"` | ||||
| } | ||||
| 
 | ||||
| type NameserverDomain struct { | ||||
| 	RoId     int    `mapstructure:"roId"` | ||||
| 	Domain   string `mapstructure:"domain"` | ||||
| 	Type     string `mapstructure:"type"` | ||||
| 	MasterIp string `mapstructure:"masterIp"` | ||||
| 	Mail     string `mapstructure:"mail"` | ||||
| 	Web      string `mapstructure:"web"` | ||||
| 	Url      string `mapstructure:"url"` | ||||
| 	Ipv4     string `mapstructure:"ipv4"` | ||||
| 	Ipv6     string `mapstructure:"ipv6"` | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) Check(domain string, nameservers []string) (*NameserverCheckResponse, error) { | ||||
| // Check Checks a domain on nameservers. | ||||
| func (s *NameserverService) Check(domain string, nameservers []string) (*NameserverCheckResponse, error) { | ||||
| 	req := s.client.NewRequest(methodNameserverCheck, map[string]interface{}{ | ||||
| 		"domain": domain, | ||||
| 		"ns":     nameservers, | ||||
| @@ -148,7 +45,8 @@ func (s *NameserverServiceOp) Check(domain string, nameservers []string) (*Names | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) Info(request *NameserverInfoRequest) (*NamserverInfoResponse, error) { | ||||
| // Info Gets informations. | ||||
| func (s *NameserverService) Info(request *NameserverInfoRequest) (*NamserverInfoResponse, error) { | ||||
| 	req := s.client.NewRequest(methodNameserverInfo, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| @@ -164,7 +62,8 @@ func (s *NameserverServiceOp) Info(request *NameserverInfoRequest) (*NamserverIn | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) List(domain string) (*NamserverListResponse, error) { | ||||
| // List List nameservers for a domain. | ||||
| func (s *NameserverService) List(domain string) (*NamserverListResponse, error) { | ||||
| 	requestMap := map[string]interface{}{ | ||||
| 		"domain": "*", | ||||
| 		"wide":   2, | ||||
| @@ -187,7 +86,8 @@ func (s *NameserverServiceOp) List(domain string) (*NamserverListResponse, error | ||||
| 	return &result, nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) Create(request *NameserverCreateRequest) (int, error) { | ||||
| // Create Creates a namesever. | ||||
| func (s *NameserverService) Create(request *NameserverCreateRequest) (int, error) { | ||||
| 	req := s.client.NewRequest(methodNameserverCreate, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| @@ -204,7 +104,8 @@ func (s *NameserverServiceOp) Create(request *NameserverCreateRequest) (int, err | ||||
| 	return result["roId"], nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) CreateRecord(request *NameserverRecordRequest) (int, error) { | ||||
| // CreateRecord Creates a DNS record. | ||||
| func (s *NameserverService) CreateRecord(request *NameserverRecordRequest) (int, error) { | ||||
| 	req := s.client.NewRequest(methodNameserverCreateRecord, structs.Map(request)) | ||||
| 
 | ||||
| 	resp, err := s.client.Do(*req) | ||||
| @@ -221,12 +122,13 @@ func (s *NameserverServiceOp) CreateRecord(request *NameserverRecordRequest) (in | ||||
| 	return result["id"], nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) UpdateRecord(recId int, request *NameserverRecordRequest) error { | ||||
| // UpdateRecord Updates a DNS record. | ||||
| func (s *NameserverService) UpdateRecord(recID int, request *NameserverRecordRequest) error { | ||||
| 	if request == nil { | ||||
| 		return errors.New("Request can't be nil") | ||||
| 		return errors.New("request can't be nil") | ||||
| 	} | ||||
| 	requestMap := structs.Map(request) | ||||
| 	requestMap["id"] = recId | ||||
| 	requestMap["id"] = recID | ||||
| 
 | ||||
| 	req := s.client.NewRequest(methodNameserverUpdateRecord, requestMap) | ||||
| 
 | ||||
| @@ -238,9 +140,10 @@ func (s *NameserverServiceOp) UpdateRecord(recId int, request *NameserverRecordR | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) DeleteRecord(recId int) error { | ||||
| // DeleteRecord Deletes a DNS record. | ||||
| func (s *NameserverService) DeleteRecord(recID int) error { | ||||
| 	req := s.client.NewRequest(methodNameserverDeleteRecord, map[string]interface{}{ | ||||
| 		"id": recId, | ||||
| 		"id": recID, | ||||
| 	}) | ||||
| 
 | ||||
| 	_, err := s.client.Do(*req) | ||||
| @@ -251,25 +154,130 @@ func (s *NameserverServiceOp) DeleteRecord(recId int) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (s *NameserverServiceOp) FindRecordById(recId int) (*NameserverRecord, *NameserverDomain, error) { | ||||
| // FindRecordByID Search a DNS record by ID. | ||||
| func (s *NameserverService) FindRecordByID(recID int) (*NameserverRecord, *NameserverDomain, error) { | ||||
| 	listResp, err := s.client.Nameservers.List("") | ||||
| 	if err != nil { | ||||
| 		return nil, nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	for _, domainItem := range listResp.Domains { | ||||
| 		resp, err := s.client.Nameservers.Info(&NameserverInfoRequest{RoId: domainItem.RoId}) | ||||
| 		resp, err := s.client.Nameservers.Info(&NameserverInfoRequest{RoID: domainItem.RoID}) | ||||
| 		if err != nil { | ||||
| 			return nil, nil, err | ||||
| 		} | ||||
| 
 | ||||
| 		for _, record := range resp.Records { | ||||
| 			if record.Id == recId { | ||||
| 			if record.ID == recID { | ||||
| 				return &record, &domainItem, nil | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	return nil, nil, fmt.Errorf("couldn't find INWX Record for id %d", recId) | ||||
| 	return nil, nil, fmt.Errorf("couldn't find INWX Record for id %d", recID) | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| // NameserverCheckResponse API model. | ||||
| type NameserverCheckResponse struct { | ||||
| 	Details []string | ||||
| 	Status  string | ||||
| } | ||||
| 
 | ||||
| // NameserverRecordRequest API model. | ||||
| type NameserverRecordRequest struct { | ||||
| 	RoID                   int    `structs:"roId,omitempty"` | ||||
| 	Domain                 string `structs:"domain,omitempty"` | ||||
| 	Type                   string `structs:"type"` | ||||
| 	Content                string `structs:"content"` | ||||
| 	Name                   string `structs:"name,omitempty"` | ||||
| 	TTL                    int    `structs:"ttl,omitempty"` | ||||
| 	Priority               int    `structs:"prio,omitempty"` | ||||
| 	URLRedirectType        string `structs:"urlRedirectType,omitempty"` | ||||
| 	URLRedirectTitle       string `structs:"urlRedirectTitle,omitempty"` | ||||
| 	URLRedirectDescription string `structs:"urlRedirectDescription,omitempty"` | ||||
| 	URLRedirectFavIcon     string `structs:"urlRedirectFavIcon,omitempty"` | ||||
| 	URLRedirectKeywords    string `structs:"urlRedirectKeywords,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // NameserverCreateRequest API model. | ||||
| type NameserverCreateRequest struct { | ||||
| 	Domain                 string   `structs:"domain"` | ||||
| 	Type                   string   `structs:"type"` | ||||
| 	Nameservers            []string `structs:"ns,omitempty"` | ||||
| 	MasterIP               string   `structs:"masterIp,omitempty"` | ||||
| 	Web                    string   `structs:"web,omitempty"` | ||||
| 	Mail                   string   `structs:"mail,omitempty"` | ||||
| 	SoaEmail               string   `structs:"soaEmail,omitempty"` | ||||
| 	URLRedirectType        string   `structs:"urlRedirectType,omitempty"` | ||||
| 	URLRedirectTitle       string   `structs:"urlRedirectTitle,omitempty"` | ||||
| 	URLRedirectDescription string   `structs:"urlRedirectDescription,omitempty"` | ||||
| 	URLRedirectFavIcon     string   `structs:"urlRedirectFavIcon,omitempty"` | ||||
| 	URLRedirectKeywords    string   `structs:"urlRedirectKeywords,omitempty"` | ||||
| 	Testing                bool     `structs:"testing,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // NameserverInfoRequest API model. | ||||
| type NameserverInfoRequest struct { | ||||
| 	Domain   string `structs:"domain,omitempty"` | ||||
| 	RoID     int    `structs:"roId,omitempty"` | ||||
| 	RecordID int    `structs:"recordId,omitempty"` | ||||
| 	Type     string `structs:"type,omitempty"` | ||||
| 	Name     string `structs:"name,omitempty"` | ||||
| 	Content  string `structs:"content,omitempty"` | ||||
| 	TTL      int    `structs:"ttl,omitempty"` | ||||
| 	Priority int    `structs:"prio,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // NamserverInfoResponse API model. | ||||
| type NamserverInfoResponse struct { | ||||
| 	RoID          int                `mapstructure:"roId"` | ||||
| 	Domain        string             `mapstructure:"domain"` | ||||
| 	Type          string             `mapstructure:"type"` | ||||
| 	MasterIP      string             `mapstructure:"masterIp"` | ||||
| 	LastZoneCheck time.Time          `mapstructure:"lastZoneCheck"` | ||||
| 	SlaveDNS      []SlaveInfo        `mapstructure:"slaveDns"` | ||||
| 	SOASerial     string             `mapstructure:"SOAserial"` | ||||
| 	Count         int                `mapstructure:"count"` | ||||
| 	Records       []NameserverRecord `mapstructure:"record"` | ||||
| } | ||||
| 
 | ||||
| // SlaveInfo API model. | ||||
| type SlaveInfo struct { | ||||
| 	Name string `mapstructure:"name"` | ||||
| 	IP   string `mapstructure:"ip"` | ||||
| } | ||||
| 
 | ||||
| // NameserverRecord API model. | ||||
| type NameserverRecord struct { | ||||
| 	ID                     int    `mapstructure:"id"` | ||||
| 	Name                   string `mapstructure:"name"` | ||||
| 	Type                   string `mapstructure:"type"` | ||||
| 	Content                string `mapstructure:"content"` | ||||
| 	TTL                    int    `mapstructure:"TTL"` | ||||
| 	Priority               int    `mapstructure:"prio"` | ||||
| 	URLRedirectType        string `mapstructure:"urlRedirectType"` | ||||
| 	URLRedirectTitle       string `mapstructure:"urlRedirectTitle"` | ||||
| 	URLRedirectDescription string `mapstructure:"urlRedirectDescription"` | ||||
| 	URLRedirectKeywords    string `mapstructure:"urlRedirectKeywords"` | ||||
| 	URLRedirectFavIcon     string `mapstructure:"urlRedirectFavIcon"` | ||||
| } | ||||
| 
 | ||||
| // NamserverListResponse API model. | ||||
| type NamserverListResponse struct { | ||||
| 	Count   int | ||||
| 	Domains []NameserverDomain `mapstructure:"domains"` | ||||
| } | ||||
| 
 | ||||
| // NameserverDomain API model. | ||||
| type NameserverDomain struct { | ||||
| 	RoID     int    `mapstructure:"roId"` | ||||
| 	Domain   string `mapstructure:"domain"` | ||||
| 	Type     string `mapstructure:"type"` | ||||
| 	MasterIP string `mapstructure:"masterIp"` | ||||
| 	Mail     string `mapstructure:"mail"` | ||||
| 	Web      string `mapstructure:"web"` | ||||
| 	URL      string `mapstructure:"url"` | ||||
| 	Ipv4     string `mapstructure:"ipv4"` | ||||
| 	Ipv6     string `mapstructure:"ipv6"` | ||||
| } | ||||
							
								
								
									
										28
									
								
								vendor/github.com/nrdcg/goinwx/response.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/nrdcg/goinwx/response.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| package goinwx | ||||
|  | ||||
| import "fmt" | ||||
|  | ||||
| // Response is a INWX API response. This wraps the standard http.Response returned from INWX. | ||||
| type Response struct { | ||||
| 	Code         int                    `xmlrpc:"code"` | ||||
| 	Message      string                 `xmlrpc:"msg"` | ||||
| 	ReasonCode   string                 `xmlrpc:"reasonCode"` | ||||
| 	Reason       string                 `xmlrpc:"reason"` | ||||
| 	ResponseData map[string]interface{} `xmlrpc:"resData"` | ||||
| } | ||||
|  | ||||
| // An ErrorResponse reports the error caused by an API request | ||||
| type ErrorResponse struct { | ||||
| 	Code       int    `xmlrpc:"code"` | ||||
| 	Message    string `xmlrpc:"msg"` | ||||
| 	ReasonCode string `xmlrpc:"reasonCode"` | ||||
| 	Reason     string `xmlrpc:"reason"` | ||||
| } | ||||
|  | ||||
| func (r *ErrorResponse) Error() string { | ||||
| 	if r.Reason != "" { | ||||
| 		return fmt.Sprintf("(%d) %s. Reason: (%s) %s", | ||||
| 			r.Code, r.Message, r.ReasonCode, r.Reason) | ||||
| 	} | ||||
| 	return fmt.Sprintf("(%d) %s", r.Code, r.Message) | ||||
| } | ||||
							
								
								
									
										133
									
								
								vendor/github.com/smueller18/goinwx/goinwx.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										133
									
								
								vendor/github.com/smueller18/goinwx/goinwx.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,133 +0,0 @@ | ||||
| package goinwx | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
|  | ||||
| 	"github.com/kolo/xmlrpc" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	libraryVersion    = "0.4.0" | ||||
| 	APIBaseUrl        = "https://api.domrobot.com/xmlrpc/" | ||||
| 	APISandboxBaseUrl = "https://api.ote.domrobot.com/xmlrpc/" | ||||
| 	APILanguage       = "eng" | ||||
| ) | ||||
|  | ||||
| // Client manages communication with INWX API. | ||||
| type Client struct { | ||||
| 	// HTTP client used to communicate with the INWX API. | ||||
| 	RPCClient *xmlrpc.Client | ||||
|  | ||||
| 	// Base URL for API requests. | ||||
| 	BaseURL *url.URL | ||||
|  | ||||
| 	// API username | ||||
| 	Username string | ||||
|  | ||||
| 	// API password | ||||
| 	Password string | ||||
|  | ||||
| 	// User agent for client | ||||
| 	APILanguage string | ||||
|  | ||||
| 	// Services used for communicating with the API | ||||
| 	Account     AccountService | ||||
| 	Domains     DomainService | ||||
| 	Nameservers NameserverService | ||||
| 	Contacts    ContactService | ||||
| } | ||||
|  | ||||
| type ClientOptions struct { | ||||
| 	Sandbox bool | ||||
| } | ||||
|  | ||||
| type Request struct { | ||||
| 	ServiceMethod string | ||||
| 	Args          map[string]interface{} | ||||
| } | ||||
|  | ||||
| // Response is a INWX API response. This wraps the standard http.Response returned from INWX. | ||||
| type Response struct { | ||||
| 	Code         int                    `xmlrpc:"code"` | ||||
| 	Message      string                 `xmlrpc:"msg"` | ||||
| 	ReasonCode   string                 `xmlrpc:"reasonCode"` | ||||
| 	Reason       string                 `xmlrpc:"reason"` | ||||
| 	ResponseData map[string]interface{} `xmlrpc:"resData"` | ||||
| } | ||||
|  | ||||
| // An ErrorResponse reports the error caused by an API request | ||||
| type ErrorResponse struct { | ||||
| 	Code       int    `xmlrpc:"code"` | ||||
| 	Message    string `xmlrpc:"msg"` | ||||
| 	ReasonCode string `xmlrpc:"reasonCode"` | ||||
| 	Reason     string `xmlrpc:"reason"` | ||||
| } | ||||
|  | ||||
| // NewClient returns a new INWX API client. | ||||
| func NewClient(username, password string, opts *ClientOptions) *Client { | ||||
| 	var useSandbox bool | ||||
| 	if opts != nil { | ||||
| 		useSandbox = opts.Sandbox | ||||
| 	} | ||||
|  | ||||
| 	var baseURL *url.URL | ||||
|  | ||||
| 	if useSandbox { | ||||
| 		baseURL, _ = url.Parse(APISandboxBaseUrl) | ||||
| 	} else { | ||||
| 		baseURL, _ = url.Parse(APIBaseUrl) | ||||
| 	} | ||||
|  | ||||
| 	rpcClient, _ := xmlrpc.NewClient(baseURL.String(), nil) | ||||
|  | ||||
| 	client := &Client{RPCClient: rpcClient, | ||||
| 		BaseURL:  baseURL, | ||||
| 		Username: username, | ||||
| 		Password: password, | ||||
| 	} | ||||
|  | ||||
| 	client.Account = &AccountServiceOp{client: client} | ||||
| 	client.Domains = &DomainServiceOp{client: client} | ||||
| 	client.Nameservers = &NameserverServiceOp{client: client} | ||||
| 	client.Contacts = &ContactServiceOp{client: client} | ||||
|  | ||||
| 	return client | ||||
| } | ||||
|  | ||||
| // NewRequest creates an API request. | ||||
| func (c *Client) NewRequest(serviceMethod string, args map[string]interface{}) *Request { | ||||
| 	if args != nil { | ||||
| 		args["lang"] = APILanguage | ||||
| 	} | ||||
|  | ||||
| 	return &Request{ServiceMethod: serviceMethod, Args: args} | ||||
| } | ||||
|  | ||||
| // Do sends an API request and returns the API response. | ||||
| func (c *Client) Do(req Request) (*map[string]interface{}, error) { | ||||
| 	var resp Response | ||||
| 	err := c.RPCClient.Call(req.ServiceMethod, req.Args, &resp) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	return &resp.ResponseData, CheckResponse(&resp) | ||||
| } | ||||
|  | ||||
| func (r *ErrorResponse) Error() string { | ||||
| 	if r.Reason != "" { | ||||
| 		return fmt.Sprintf("(%d) %s. Reason: (%s) %s", | ||||
| 			r.Code, r.Message, r.ReasonCode, r.Reason) | ||||
| 	} | ||||
| 	return fmt.Sprintf("(%d) %s", r.Code, r.Message) | ||||
| } | ||||
|  | ||||
| // CheckResponse checks the API response for errors, and returns them if present. | ||||
| func CheckResponse(r *Response) error { | ||||
| 	if c := r.Code; c >= 1000 && c <= 1500 { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	return &ErrorResponse{Code: r.Code, Message: r.Message, Reason: r.Reason, ReasonCode: r.ReasonCode} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user