domain.go raw

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