| 1 | package dnsimplescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.21 context/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.21 fmt/" |
| 6 | ) |
| 7 | |
| 8 | // DomainsService handles communication with the domain related |
| 9 | // methods of the DNSimple API. |
| 10 | // |
| 11 | // See https://developer.dnsimple.com/v2/domains/ |
| 12 | type DomainsServicescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService# struct { |
| 13 | clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#client. *Clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Client# |
| 14 | } |
| 15 | |
| 16 | // Domain represents a domain in DNSimple. |
| 17 | type Domainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain# struct { |
| 18 | IDscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#ID. int64 `json:"id,omitempty"` |
| 19 | AccountIDscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#AccountID. int64 `json:"account_id,omitempty"` |
| 20 | RegistrantIDscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#RegistrantID. int64 `json:"registrant_id,omitempty"` |
| 21 | Namescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#Name. string `json:"name,omitempty"` |
| 22 | UnicodeNamescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#UnicodeName. string `json:"unicode_name,omitempty"` |
| 23 | Tokenscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#Token. string `json:"token,omitempty"` |
| 24 | Statescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#State. string `json:"state,omitempty"` |
| 25 | AutoRenewscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#AutoRenew. bool `json:"auto_renew,omitempty"` |
| 26 | PrivateWhoisscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#PrivateWhois. bool `json:"private_whois,omitempty"` |
| 27 | ExpiresAtscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#ExpiresAt. string `json:"expires_at,omitempty"` |
| 28 | CreatedAtscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#CreatedAt. string `json:"created_at,omitempty"` |
| 29 | UpdatedAtscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#UpdatedAt. string `json:"updated_at,omitempty"` |
| 30 | } |
| 31 | |
| 32 | func domainPathscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/domainPath().(accountID string, domainIdentifier string) (path string) { |
| 33 | path = fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("/%v/domains", accountID) |
| 34 | if domainIdentifier != "" { |
| 35 | path += fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("/%v", domainIdentifier) |
| 36 | } |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | // DomainResponse represents a response from an API method that returns a Domain struct. |
| 41 | type DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse# struct { |
| 42 | Responsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#Response. |
| 43 | Datascip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#Data. *Domainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain# `json:"data"` |
| 44 | } |
| 45 | |
| 46 | // DomainsResponse represents a response from an API method that returns a collection of Domain struct. |
| 47 | type DomainsResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsResponse# struct { |
| 48 | Responsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsResponse#Response. |
| 49 | Datascip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsResponse#Data. []Domainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain# `json:"data"` |
| 50 | } |
| 51 | |
| 52 | // DomainListOptions specifies the optional parameters you can provide |
| 53 | // to customize the DomainsService.ListDomains method. |
| 54 | type DomainListOptionsscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainListOptions# struct { |
| 55 | // Select domains where the name contains given string. |
| 56 | NameLikescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainListOptions#NameLike. *string `url:"name_like,omitempty"` |
| 57 | |
| 58 | // Select domains where the registrant matches given ID. |
| 59 | RegistrantIDscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainListOptions#RegistrantID. *int `url:"registrant_id,omitempty"` |
| 60 | |
| 61 | ListOptionsscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainListOptions#ListOptions. |
| 62 | } |
| 63 | |
| 64 | // ListDomains lists the domains for an account. |
| 65 | // |
| 66 | // See https://developer.dnsimple.com/v2/domains/#list |
| 67 | func (s *DomainsServicescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#) ListDomainsscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#ListDomains().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, accountID string, options *DomainListOptionsscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainListOptions#) (*DomainsResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsResponse#, error) { |
| 68 | path := versionedscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/versioned().(domainPathscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/domainPath().(accountID, "")) |
| 69 | domainsResponse := &DomainsResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsResponse#{} |
| 70 | |
| 71 | path, err := addURLQueryOptionsscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/addURLQueryOptions().(path, options) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | |
| 76 | resp, err := s.clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#client..getscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Client#get().(ctx, path, domainsResponse) |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | |
| 81 | domainsResponse.HTTPResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Response#HTTPResponse. = resp |
| 82 | return domainsResponse, nil |
| 83 | } |
| 84 | |
| 85 | // CreateDomain creates a new domain in the account. |
| 86 | // |
| 87 | // See https://developer.dnsimple.com/v2/domains/#create |
| 88 | func (s *DomainsServicescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#) CreateDomainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#CreateDomain().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, accountID string, domainAttributes Domainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Domain#) (*DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#, error) { |
| 89 | path := versionedscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/versioned().(domainPathscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/domainPath().(accountID, "")) |
| 90 | domainResponse := &DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#{} |
| 91 | |
| 92 | resp, err := s.clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#client..postscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Client#post().(ctx, path, domainAttributes, domainResponse) |
| 93 | if err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | |
| 97 | domainResponse.HTTPResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Response#HTTPResponse. = resp |
| 98 | return domainResponse, nil |
| 99 | } |
| 100 | |
| 101 | // GetDomain fetches a domain. |
| 102 | // |
| 103 | // See https://developer.dnsimple.com/v2/domains/#get |
| 104 | func (s *DomainsServicescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#) GetDomainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#GetDomain().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, accountID string, domainIdentifier string) (*DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#, error) { |
| 105 | path := versionedscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/versioned().(domainPathscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/domainPath().(accountID, domainIdentifier)) |
| 106 | domainResponse := &DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#{} |
| 107 | |
| 108 | resp, err := s.clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#client..getscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Client#get().(ctx, path, domainResponse) |
| 109 | if err != nil { |
| 110 | return nil, err |
| 111 | } |
| 112 | |
| 113 | domainResponse.HTTPResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Response#HTTPResponse. = resp |
| 114 | return domainResponse, nil |
| 115 | } |
| 116 | |
| 117 | // DeleteDomain PERMANENTLY deletes a domain from the account. |
| 118 | // |
| 119 | // See https://developer.dnsimple.com/v2/domains/#delete |
| 120 | func (s *DomainsServicescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#) DeleteDomainscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#DeleteDomain().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, accountID string, domainIdentifier string) (*DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#, error) { |
| 121 | path := versionedscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/versioned().(domainPathscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/domainPath().(accountID, domainIdentifier)) |
| 122 | domainResponse := &DomainResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainResponse#{} |
| 123 | |
| 124 | resp, err := s.clientscip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/DomainsService#client..deletescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Client#delete().(ctx, path, nil, nil) |
| 125 | if err != nil { |
| 126 | return nil, err |
| 127 | } |
| 128 | |
| 129 | domainResponse.HTTPResponsescip-go gomod github.com/dnsimple/dnsimple-go . `github.com/dnsimple/dnsimple-go/dnsimple`/Response#HTTPResponse. = resp |
| 130 | return domainResponse, nil |
| 131 | } |