1package domain
2
3import (
4	"github.com/transip/gotransip/v6/rest"
5	"net"
6)
7
8// PerformAction List of available actions to perform on this domain.
9// Possible actions are: 'register', 'transfer', 'internalpull' and 'internalpush'
10type PerformAction string
11
12// define all possible actions that a user can perform on a domain
13const (
14	// PerformActionTransfer is the available perform transfer action
15	PerformActionTransfer PerformAction = "transfer"
16	// PerformActionInternalPull is the available perform internalpull action,
17	// for when a domain is at transip and can be handovered pushed/pulled towards a different account
18	PerformActionInternalPull PerformAction = "internalpull"
19	// PerformActionInternalPush is the available perform internalpush action,
20	// for when a domain is at transip and can be handovered pushed/pulled towards a different account
21	PerformActionInternalPush PerformAction = "internalpush"
22)
23
24// AvailabilityStatus is the status for a domain. Returned during queries upon the availability
25// Possible statuses are: 'inyouraccount', 'unavailable', 'notfree', 'free', 'internalpull', 'internalpush'
26type AvailabilityStatus string
27
28// define all possible availability statuses
29const (
30	// AvailabilityStatusInYourAccount is the availability status for when a domain is already in your account
31	AvailabilityStatusInyouraccount AvailabilityStatus = "inyouraccount"
32	// AvailabilityStatusUnavailable is the availability status for when a domain is unavailable
33	AvailabilityStatusUnavailable AvailabilityStatus = "unavailable"
34	// AvailabilityStatusNotFree is the availability status for when a domain is already taken
35	AvailabilityStatusNotFree AvailabilityStatus = "notfree"
36	// AvailabilityStatusFree is the availability status for when a domain is free to register
37	AvailabilityStatusFree AvailabilityStatus = "free"
38	// AvailabilityStatusInternalPull is the availability status,
39	// for when a domain is at transip and can be handovered pushed/pulled towards a different account
40	AvailabilityStatusInternalPull AvailabilityStatus = "internalpull"
41	// AvailabilityStatusInternalPush is the availability status,
42	// for when a domain is at transip and can be handovered pushed/pulled towards a different account
43	AvailabilityStatusInternalPush AvailabilityStatus = "internalpush"
44)
45
46// domainsResponse struct contains a list of Domains in it,
47// this is solely used for unmarshalling/marshalling
48type domainsResponse struct {
49	Domains []Domain `json:"domains"`
50}
51
52// domainWrapper struct contains a Domain in it,
53// this is solely used for unmarshalling/marshalling
54type domainWrapper struct {
55	Domain Domain `json:"domain"`
56}
57
58// domainBrandingWrapper struct contains a Branding struct in it,
59// this is solely used for unmarshalling/marshalling
60type domainBrandingWrapper struct {
61	Branding Branding `json:"branding"`
62}
63
64// dnsEntriesWrapper struct contains a DNSEntry list in it,
65// this is solely used for unmarshalling/marshalling
66type dnsEntriesWrapper struct {
67	DNSEntries []DNSEntry `json:"dnsEntries"`
68}
69
70// dnsEntryWrapper struct contains a DNSEntry struct in it,
71// this is solely used for unmarshalling/marshalling
72type dnsEntryWrapper struct {
73	DNSEntry DNSEntry `json:"dnsEntry"`
74}
75
76// contactsWrapper struct contains a list of Contacts in it,
77// this is solely used for unmarshalling/marshalling
78type contactsWrapper struct {
79	Contacts []WhoisContact `json:"contacts"`
80}
81
82// dnsSecEntriesWrapper struct contains a list of DNSSecEntry in it,
83// this is solely used for unmarshalling/marshalling
84type dnsSecEntriesWrapper struct {
85	// All DNSSEC entries for a domain
86	DNSSecEntries []DNSSecEntry `json:"dnsSecEntries"`
87}
88
89// nameserversWrapper struct contains a list of Nameservers in it,
90// this is solely used for unmarshalling/marshalling
91type nameserversWrapper struct {
92	Nameservers []Nameserver `json:"nameservers"`
93}
94
95// actionWrapper struct contains a Action in it, this is solely used for unmarshalling/marshalling
96type actionWrapper struct {
97	Action Action `json:"action"`
98}
99
100// retryActionWrapper object is used to create a retry action request body
101type retryActionWrapper struct {
102	// The authcode for this domain as generated by the registry.
103	AuthCode string `json:"authCode,omitempty"`
104	// Optionally you can set different domain dns entries
105	DNSEntries []DNSEntry `json:"dnsEntries,omitempty"`
106	// Optionally you can set different nameservers
107	Nameservers []Nameserver `json:"nameservers,omitempty"`
108	// Optionally you can set different whois contacts
109	Contacts []WhoisContact `json:"contacts"`
110}
111
112// certificatesWrapper struct contains a list of SslCertificates in it,
113// this is solely used for unmarshalling
114type certificatesWrapper struct {
115	Certificates []SslCertificate `json:"certificates"`
116}
117
118// certificateWrapper struct contains a SslCertificate in it,
119// this is solely used for unmarshalling
120type certificateWrapper struct {
121	Certificate SslCertificate `json:"certificate"`
122}
123
124// whoisWrapper struct contains a whois string in it,
125// this is solely used for unmarshalling
126type whoisWrapper struct {
127	Whois string `json:"whois"`
128}
129
130// availabilityWrapper struct contains a Availability struct in it,
131// this is solely used for unmarshalling
132type availabilityWrapper struct {
133	Availability Availability `json:"availability"`
134}
135
136// availabilityListWrapper struct contains a list of Availability structs in it,
137// this is solely used for unmarshalling
138type availabilityListWrapper struct {
139	AvailabilityList []Availability `json:"availability"`
140}
141
142// this struct is used to generate a json request
143// for the multiple domain names availability option
144type multipleAvailabilityRequest struct {
145	DomainNames []string `json:"domainNames"`
146}
147
148// tldsWrapper struct contains a list of Tlds in it,
149// this is solely used for unmarshalling
150type tldsWrapper struct {
151	Tlds []Tld `json:"tlds"`
152}
153
154// tldWrapper struct contains a list of Tld in it,
155// this is solely used for unmarshalling
156type tldWrapper struct {
157	Tld Tld `json:"tld"`
158}
159
160// Contact struct for a Contact
161type Contact struct {
162	// Email address of the contact
163	Email string `json:"email"`
164	// ID number of the contact
165	ID int64 `json:"id"`
166	// Name of the contact
167	Name string `json:"name"`
168	// Telephone number of the contact
169	Telephone string `json:"telephone"`
170}
171
172// DNSEntry struct for a DNSEntry
173type DNSEntry struct {
174	// The name of the dns entry, for example '@' or 'www'
175	Name string `json:"name"`
176	// The expiration period of the dns entry, in seconds. For example 86400 for a day of expiration
177	Expire int `json:"expire"`
178	// The type of dns entry. Possbible types are 'A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV', 'SSHFP' and 'TLSA'
179	Type string `json:"type"`
180	// The content of of the dns entry, for example '10 mail', '127.0.0.1' or 'www'
181	Content string `json:"content"`
182}
183
184// WhoisContact struct for a whois contact
185type WhoisContact struct {
186	// The type of this Contact, 'registrant', 'administrative' or 'technical'
187	Type string `json:"type"`
188	// The firstName of this Contact
189	FirstName string `json:"firstName"`
190	// The lastName of this Contact
191	LastName string `json:"lastName"`
192	// The companyName of this Contact, in case of a company
193	CompanyName string `json:"companyName"`
194	// The kvk number of this Contact, in case of a company
195	CompanyKvk string `json:"companyKvk"`
196	// The type number of this Contact, in case of a company.
197	// Possible types are: 'BV', 'BVI/O', 'COOP', 'CV', 'EENMANSZAAK', 'KERK', 'NV',
198	// 'OWM', 'REDR', 'STICHTING', 'VERENIGING', 'VOF', 'BEG', 'BRO', 'EESV' and 'ANDERS'
199	CompanyType string `json:"companyType"`
200	// The street of the address of this Contact
201	Street string `json:"street"`
202	// The number part of the address of this Contact
203	Number string `json:"number"`
204	// The postalCode part of the address of this Contact
205	PostalCode string `json:"postalCode"`
206	// The city part of the address of this Contact
207	City string `json:"city"`
208	// The phoneNumber of this Contact
209	PhoneNumber string `json:"phoneNumber"`
210	// The faxNumber of this Contact
211	FaxNumber string `json:"faxNumber,omitempty"`
212	// The email address of this Contact
213	Email string `json:"email"`
214	// The country of this Contact, one of the ISO 3166-1 2 letter country codes, must be lowercase.
215	Country string `json:"country"`
216}
217
218// Action struct for a domain Action
219type Action struct {
220	// If this action has failed, this field will be true.
221	HasFailed bool `json:"hasFailed,omitempty"`
222	// If this action has failed, this field will contain an descriptive message.
223	Message string `json:"message,omitempty"`
224	// The name of this Action.
225	Name string `json:"name"`
226}
227
228// SslCertificate struct for a SslCertificate
229type SslCertificate struct {
230	// The id of the certificate, can be used to retrieve additional info
231	CertificateID int `json:"certificateId"`
232	// The domain name that the SSL certificate is added to. Start with '*.' when the certificate is a wildcard.
233	CommonName string `json:"commonName"`
234	// Expiration date
235	ExpirationDate string `json:"expirationDate"`
236	// The current status, either 'active', 'inactive' or 'expired'
237	Status string `json:"status"`
238}
239
240// Domain struct for a Domain
241type Domain struct {
242	// The custom tags added to this domain.
243	Tags []string `json:"tags"`
244	// The authcode for this domain as generated by the registry.
245	AuthCode string `json:"authCode,omitempty"`
246	// Cancellation data, in YYYY-mm-dd h:i:s format, null if the domain is active.
247	CancellationDate rest.Time `json:"cancellationDate,omitempty"`
248	// Cancellation status, null if the domain is active, 'cancelled' when the domain is cancelled.
249	CancellationStatus string `json:"cancellationStatus,omitempty"`
250	// Whether this domain is DNS only
251	IsDNSOnly bool `json:"isDnsOnly,omitempty"`
252	// If this domain supports transfer locking, this flag is true when the domains ability to transfer is locked at the registry.
253	IsTransferLocked bool `json:"isTransferLocked"`
254	// If this domain is added to your whitelabel.
255	IsWhitelabel bool `json:"isWhitelabel"`
256	// The name, including the tld of this domain
257	Name string `json:"name"`
258	// Registration date of the domain, in YYYY-mm-dd format.
259	RegistrationDate rest.Date `json:"registrationDate,omitempty"`
260	// Next renewal date of the domain, in YYYY-mm-dd format.
261	RenewalDate rest.Date `json:"renewalDate,omitempty"`
262}
263
264// Branding struct for a Branding, this information is shown in the whois information
265type Branding struct {
266	// The first generic bannerLine displayed in whois-branded whois output.
267	BannerLine1 string `json:"bannerLine1"`
268	// The second generic bannerLine displayed in whois-branded whois output.
269	BannerLine2 string `json:"bannerLine2"`
270	// The third generic bannerLine displayed in whois-branded whois output.
271	BannerLine3 string `json:"bannerLine3"`
272	// The company name displayed in transfer-branded e-mails
273	CompanyName string `json:"companyName"`
274	// The company url displayed in transfer-branded e-mails
275	CompanyURL string `json:"companyUrl"`
276	// The support email used for transfer-branded e-mails
277	SupportEmail string `json:"supportEmail"`
278	// The terms of usage url as displayed in transfer-branded e-mails
279	TermsOfUsageURL string `json:"termsOfUsageUrl"`
280}
281
282// DNSSecEntry struct for a DNSSecEntry
283type DNSSecEntry struct {
284	// The algorithm type that is used,
285	// see: https://www.transip.nl/vragen/461-domeinnaam-nameservers-gebruikt-beveiligen-dnssec/ for the possible options.
286	Algorithm int `json:"algorithm"`
287	// The signing key number, either 256 (Zone Signing Key) or 257 (Key Signing Key)
288	Flags int `json:"flags"`
289	// A 5-digit key of the Zonesigner
290	KeyTag int `json:"keyTag"`
291	// The public key
292	PublicKey string `json:"publicKey"`
293}
294
295// Tld struct for a Tld
296type Tld struct {
297	// Number of days a domain needs to be canceled before the renewal date.
298	CancelTimeFrame int `json:"cancelTimeFrame,omitempty"`
299	// A list of the capabilities that this Tld has (the things that can be done with a domain under this tld).
300	// Possible capabilities are: 'requiresAuthCode', 'canRegister', 'canTransferWithOwnerChange',
301	// 'canTransferWithoutOwnerChange', 'canSetLock', 'canSetOwner', 'canSetContacts', 'canSetNameservers',
302	// 'supportsDnsSec'
303	Capabilities []string `json:"capabilities,omitempty"`
304	// The maximum amount of characters need for registering a domain under this TLD.
305	MaxLength int `json:"maxLength,omitempty"`
306	// The minimum amount of characters need for registering a domain under this TLD.
307	MinLength int `json:"minLength,omitempty"`
308	// The name of this TLD, including the starting dot. E.g. .nl or .com.
309	Name string `json:"name"`
310	// Price of the TLD in cents
311	Price int `json:"price,omitempty"`
312	// Price for renewing the TLD in cents
313	RecurringPrice int `json:"recurringPrice,omitempty"`
314	// Length in months of each registration or renewal period.
315	RegistrationPeriodLength int `json:"registrationPeriodLength,omitempty"`
316}
317
318// Availability struct for an Availability
319type Availability struct {
320	// List of available actions to perform on this domain. Possible actions are: 'register', 'transfer', 'internalpull' and 'internalpush'
321	Actions []PerformAction `json:"actions"`
322	// The name of the domain
323	DomainName string `json:"domainName"`
324	// The status for this domain. Possible statuses are: 'inyouraccount', 'unavailable', 'notfree', 'free', 'internalpull' and 'internalpush'
325	Status AvailabilityStatus `json:"status"`
326}
327
328// Nameserver struct for a Nameserver
329type Nameserver struct {
330	// The hostname of this nameserver
331	Hostname string `json:"hostname"`
332	// Optional ipv4 glue record for this nameserver
333	IPv4 net.IP `json:"ipv4,omitempty"`
334	// Optional ipv6 glue record for this nameserver
335	IPv6 net.IP `json:"ipv6,omitempty"`
336}
337
338// Register struct used when registering a new domain
339type Register struct {
340	// The name, including the tld of the domain
341	DomainName string `json:"domainName"`
342	// Optionally you can set whois contacts
343	Contacts []Contact `json:"contacts,omitempty"`
344	// Optionally you can set the domain dns entries before transferring
345	DNSEntries []DNSEntry `json:"dnsEntries,omitempty"`
346	// Optionally you can set the domain nameservers before transferring
347	Nameservers []Nameserver `json:"nameservers,omitempty"`
348}
349
350// Transfer struct used when transferring a domain to transip
351type Transfer struct {
352	// The name, including the tld of the domain
353	DomainName string `json:"domainName"`
354	// The authcode for this domain as generated by the registry.
355	AuthCode string `json:"authCode"`
356	// Optionally you can set whois contacts
357	Contacts []Contact `json:"contacts,omitempty"`
358	// Optionally you can set the domain dns entries before transferring
359	DNSEntries []DNSEntry `json:"dnsEntries,omitempty"`
360	// Optionally you can set the domain nameservers before transferring
361	Nameservers []Nameserver `json:"nameservers,omitempty"`
362}
363