Documentation
¶
Index ¶
- type Client
- func (c *Client) CreateOrUpdateRecord(ctx context.Context, zone string, record IkRecord) (*IkRecord, error)
- func (c *Client) DeleteRecord(ctx context.Context, zone string, recordId string) error
- func (c *Client) GetDnsRecordsForZone(ctx context.Context, zone string) ([]IkRecord, error)
- func (c *Client) GetFqdnOfZoneForDomain(ctx context.Context, domain string) (string, error)
- type IkClient
- type IkIntValueAttribute
- type IkRecord
- type IkRecordDescription
- type IkResponse
- type IkStringValueAttribute
- type IkZone
- type Provider
- func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- func (p *Provider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)
- func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
- type ZoneMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// infomaniak API token
Token string
// http client used for requests
HttpClient *http.Client
}
Client that abstracts and calls infomaniak API
func (*Client) CreateOrUpdateRecord ¶
func (c *Client) CreateOrUpdateRecord(ctx context.Context, zone string, record IkRecord) (*IkRecord, error)
CreateOrUpdateRecord creates a record if its Id property is not set, otherwise it updates the record
func (*Client) DeleteRecord ¶
DeleteRecord deletes an existing dns record for a given zone
func (*Client) GetDnsRecordsForZone ¶
GetDnsRecordsForZone loads all dns records for a given zone
type IkClient ¶
type IkClient interface {
// DeleteRecord deletes record with given ID
DeleteRecord(ctx context.Context, zone string, id string) error
// CreateOrUpdateRecord creates record if it has no ID property set, otherwise it updates the record with the given ID
CreateOrUpdateRecord(ctx context.Context, zone string, record IkRecord) (*IkRecord, error)
// GetDnsRecordsForZone returns all records of the given zone
GetDnsRecordsForZone(ctx context.Context, zone string) ([]IkRecord, error)
// GetFqdnOfZoneForDomain returns the FQDN of the zone managed by infomaniak
GetFqdnOfZoneForDomain(ctx context.Context, domain string) (string, error)
}
IkClient interface to abstract infomaniak client
type IkIntValueAttribute ¶ added in v0.2.0
type IkRecord ¶
type IkRecord struct {
// ID of this record on infomaniak's side
ID int `json:"id,omitempty"`
// Type of this record
Type string `json:"type,omitempty"`
// Absolute Source / Name
Source string `json:"source,omitempty"`
// Value of this record
Target string `json:"target,omitempty"`
// TTL in seconds
TtlInSec int `json:"ttl,omitempty"`
// Record Description
Description IkRecordDescription `json:"description,omitempty"`
}
IkRecord infomaniak API record return type
func ToInfomaniakRecord ¶
func ToInfomaniakRecord(libdnsRec libdns.Record, zoneMapping *ZoneMapping) IkRecord
ToInfomaniakRecord maps a libdns record to a infomaniak dns record
func (*IkRecord) ToLibDnsRecord ¶
func (ikr *IkRecord) ToLibDnsRecord(zoneMapping *ZoneMapping) (libdns.Record, error)
ToLibDnsRecord maps a infomaniak dns record to a libdns record
type IkRecordDescription ¶ added in v0.2.0
type IkRecordDescription struct {
// Only available for SRV and MX records
Priority IkIntValueAttribute `json:"priority,omitempty"`
// Only available for SRV records
Port IkIntValueAttribute `json:"port,omitempty"`
// Only available for SRV records
Weight IkIntValueAttribute `json:"weight,omitempty"`
// Only available for SRV and DNSKEY records
Protocol IkStringValueAttribute `json:"protocol,omitempty"`
// Only available for CAA and DNSKEY records
Flags IkIntValueAttribute `json:"flags,omitempty"`
// Only available for CAA records
Tag IkStringValueAttribute `json:"tag,omitempty"`
}
type IkResponse ¶
type IkResponse struct {
// Result of the API call: either "success" or "error"
Result string `json:"result"`
// Data is set if API call was successful and contains the actual response
Data json.RawMessage `json:"data,omitempty"`
// Error is set if the API call failed and contains all errors that occurred
Error json.RawMessage `json:"error,omitempty"`
}
IkResponse infomaniak API response
type IkStringValueAttribute ¶ added in v0.2.0
type IkZone ¶ added in v0.2.0
type IkZone struct {
// Zone's FQDN on infomaniak's side
Fqdn string `json:"fqdn"`
}
IkZone infomaniak API zone return type
type Provider ¶
type Provider struct {
//infomaniak API token
APIToken string `json:"api_token,omitempty"`
// contains filtered or unexported fields
}
Provider facilitates DNS record manipulation with infomaniak.
func (*Provider) AppendRecords ¶
func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
AppendRecords creates the inputted records in the given zone and returns the populated records that were created. It never changes existing records.
Therefore, it makes little sense to use this method with CNAME-type records since if there are no existing records with the same name, it behaves the same as libdns.RecordSetter.SetRecords, and if there are existing records with the same name, it will either fail or leave the zone in an invalid state.
func (*Provider) DeleteRecords ¶
func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
DeleteRecords deletes the given records from the zone if they exist in the zone and exactly match the input. If the input records do not exist in the zone, they are silently ignored. DeleteRecords returns only the the records that were deleted, and does not return any records that were provided in the input but did not exist in the zone.
DeleteRecords only deletes records from the zone that *exactly* match the input records—that is, the name, type, TTL, and value all must be identical to a record in the zone for it to be deleted.
As a special case, you may leave any of the fields libdns.Record.Type, libdns.Record.TTL, or libdns.Record.Value empty ("", 0, and "" respectively). In this case, DeleteRecords will delete any records that match the other fields, regardless of the value of the fields that were left empty. Note that this behavior does *not* apply to the libdns.Record.Name field, which must always be specified.
func (*Provider) GetRecords ¶
GetRecords returns all the records in the DNS zone.
DNSKEY and DS are DNSSEC-related record types that are included in the output.
func (*Provider) SetRecords ¶
func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)
SetRecords updates the zone so that the records described in the input are reflected in the output.
For any (name, type) pair in the input, SetRecords ensures that the only records in the output zone with that (name, type) pair are those that were provided in the input.
In RFC 9499 terms, SetRecords appends, modifies, or deletes records in the zone so that for each RRset in the input, the records provided in the input are the only members of their RRset in the output zone.
DNSSEC-related records of type DS are supported.
Calls to SetRecords are not to be presumed atomic; that is, if err == nil, then all of the requested changes were made; if err != nil, then some changes might have been applied already. In other words, errors may result in partial changes to the zone.
If SetRecords is used to add a CNAME record to a name with other existing non-DNSSEC records, implementations may either fail with an error, add the CNAME and leave the other records in place (in violation of the DNS standards), or add the CNAME and remove the other preexisting records. Therefore, users should proceed with caution when using SetRecords with CNAME records.
type ZoneMapping ¶ added in v0.2.0
type ZoneMapping struct {
// Zone that is mangaged by infomaniak
InfomaniakManagedZone string `json:"fqdn"`
// Zone that is provided by libdns
LibDnsZone string
}
ZoneMapping represents input zone coming from the caller and the zone that is actually managed by infomaniak
func (*ZoneMapping) ToRelativeInfomaniakName ¶ added in v0.2.0
func (zoneMapping *ZoneMapping) ToRelativeInfomaniakName(relativeName string) string
ToRelativeInfomaniakName converts a relative name from input zone of the libdns caller to the infomaniak managed zone
func (*ZoneMapping) ToRelativeLibdnsName ¶ added in v0.2.0
func (zoneMapping *ZoneMapping) ToRelativeLibdnsName(relativeName string) string
ToRelativeLibdnsName converts a relative name from the infomaniak managed zone to the input zone of the libdns caller