provider

package
v0.0.0-...-10117dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	BaseURL string
	// contains filtered or unexported fields
}

Provider struct

func New

func New() (*Provider, error)

New constructor creates a given domain provider with its base URL

func (*Provider) AddRecord

func (p *Provider) AddRecord(domain string, record records.Record) error

AddRecord creates a new record in Njalla. It accepts only those record types defined in records/records

func (*Provider) GetDomains

func (p *Provider) GetDomains() ([]string, error)

GetDomains returns an array of available domains in your Njalla account

func (*Provider) GetRecords

func (p *Provider) GetRecords(domain string) (records.Records, error)

GetRecords returns Records with all the available records for a domain

func (*Provider) Login

func (p *Provider) Login(email, password string) error

Login logs a given user in

func (*Provider) RemoveRecord

func (p *Provider) RemoveRecord(domain string, recordID int) error

RemoveRecord takes a given Record ID and tries to remove it from Njalla. Because of how Njalla's website works, a "remove" operation is really just an update operation. An update operation that keeps all the records but the one you want to remove.

func (*Provider) UpdateRecord

func (p *Provider) UpdateRecord(
	domain string, recordID int, record url.Values,
) error

UpdateRecord takes a given Record ID, and a Record with its fields changed as a url.Values struct. Because of limitations with the website itself, we can't just one or more fields and send that change. We also can't just modify one record and send that only record. An update operation requires updating the fields you want from the record you want to update, but also keep all the fields you haven't modified. Also keep the rest of the records unmodified. But then you have to remove the `type` field of every record. Also convert all the fields into string. Then remove the `id` field and convert it into: {"id": { ...rest of fields... }, } So you end with a JSON that contains ID keys, and the values are the records with the `type` and `id` fields removed, and the remaining fields' values converted to string.

Take a Record you want to modify from GetRecords, call GetURLValues() on it, modify whatever you need, and then pass those url.Values to this function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL