godaddy

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultTimeout = 180 * time.Second

DefaultTimeout api requests after 180s

Variables

View Source
var (
	ErrAPIDown = errors.New("godaddy: the GoDaddy API is down")
)

Errors

View Source
var (
	// ErrRecordToMutateNotFound when ApplyChange has to update/delete and didn't found the record in the existing zone (Change with no record ID)
	ErrRecordToMutateNotFound = errors.New("record to mutate not found in current zone")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string
	Message string
}

APIError error

func (*APIError) Error

func (err *APIError) Error() string

type Client

type Client struct {
	// APIKey holds the Application key
	APIKey string

	// APISecret holds the Application secret key
	APISecret string

	// API endpoint
	APIEndPoint string

	// Client is the underlying HTTP client used to run the requests. It may be overloaded but a default one is instanciated in “NewClient“ by default.
	Client *http.Client

	// Logger is used to log HTTP requests and responses.
	Logger Logger

	Timeout time.Duration
}

Client represents a client to call the GoDaddy API

func NewClient

func NewClient(useOTE bool, apiKey, apiSecret string) (*Client, error)

NewClient represents a new client to call the API

func (*Client) CallAPI

func (c *Client) CallAPI(method, path string, reqBody, resType interface{}, needAuth bool) error

CallAPI is the lowest level call helper. If needAuth is true, inject authentication headers and sign the request.

Request signature is a sha1 hash on following fields, joined by '+': - applicationSecret (from Client instance) - consumerKey (from Client instance) - capitalized method (from arguments) - full request url, including any query string argument - full serialized request body - server current time (takes time delta into account)

Call will automatically assemble the target url from the endpoint configured in the client instance and the path argument. If the reqBody argument is not nil, it will also serialize it as json and inject the required Content-Type header.

If everything went fine, unmarshall response into resType and return nil otherwise, return the error

func (*Client) CallAPIWithContext

func (c *Client) CallAPIWithContext(ctx context.Context, method, path string, reqBody, resType interface{}, needAuth bool) error

CallAPIWithContext is the lowest level call helper. If needAuth is true, inject authentication headers and sign the request.

Request signature is a sha1 hash on following fields, joined by '+': - applicationSecret (from Client instance) - consumerKey (from Client instance) - capitalized method (from arguments) - full request url, including any query string argument - full serialized request body - server current time (takes time delta into account)

Context is used by http.Client to handle context cancelation

Call will automatically assemble the target url from the endpoint configured in the client instance and the path argument. If the reqBody argument is not nil, it will also serialize it as json and inject the required Content-Type header.

If everything went fine, unmarshall response into resType and return nil otherwise, return the error

func (*Client) Delete

func (c *Client) Delete(url string, resType interface{}) error

Delete is a wrapper for the DELETE method

func (*Client) DeleteWithContext

func (c *Client) DeleteWithContext(ctx context.Context, url string, resType interface{}) error

DeleteWithContext is a wrapper for the DELETE method

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response

func (*Client) Get

func (c *Client) Get(url string, resType interface{}) error

Get is a wrapper for the GET method

func (*Client) GetWithContext

func (c *Client) GetWithContext(ctx context.Context, url string, resType interface{}) error

GetWithContext is a wrapper for the GET method

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, reqBody interface{}, needAuth bool) (*http.Request, error)

NewRequest returns a new HTTP request

func (*Client) Patch

func (c *Client) Patch(url string, reqBody, resType interface{}) error

Patch is a wrapper for the POST method

func (*Client) PatchWithContext

func (c *Client) PatchWithContext(ctx context.Context, url string, reqBody, resType interface{}) error

PatchWithContext is a wrapper for the POST method

func (*Client) Post

func (c *Client) Post(url string, reqBody, resType interface{}) error

Post is a wrapper for the POST method

func (*Client) PostWithContext

func (c *Client) PostWithContext(ctx context.Context, url string, reqBody, resType interface{}) error

PostWithContext is a wrapper for the POST method

func (*Client) Put

func (c *Client) Put(url string, reqBody, resType interface{}) error

Put is a wrapper for the PUT method

func (*Client) PutWithContext

func (c *Client) PutWithContext(ctx context.Context, url string, reqBody, resType interface{}) error

PutWithContext is a wrapper for the PUT method

func (*Client) UnmarshalResponse

func (c *Client) UnmarshalResponse(response *http.Response, resType interface{}) error

UnmarshalResponse checks the response and unmarshals it into the response type if needed Helper function, called from CallAPI

type GDErrorField added in v0.9.0

type GDErrorField struct {
	Code        string `json:"code,omitempty"`
	Message     string `json:"message,omitempty"`
	Path        string `json:"path,omitempty"`
	PathRelated string `json:"pathRelated,omitempty"`
}

GDErrorField describe the error reason

type GDErrorResponse added in v0.9.0

type GDErrorResponse struct {
	Code    string         `json:"code"`
	Fields  []GDErrorField `json:"fields,omitempty"`
	Message string         `json:"message,omitempty"`
}

GDErrorResponse is the body response when an API call fails

func (GDErrorResponse) String added in v0.9.0

func (r GDErrorResponse) String() string

type GDProvider

type GDProvider struct {
	provider.BaseProvider

	DryRun bool
	// contains filtered or unexported fields
}

GDProvider declare GoDaddy provider

func NewGoDaddyProvider

func NewGoDaddyProvider(ctx context.Context, domainFilter endpoint.DomainFilter, ttl int64, apiKey, apiSecret string, useOTE, dryRun bool) (*GDProvider, error)

NewGoDaddyProvider initializes a new GoDaddy DNS based Provider.

func (*GDProvider) ApplyChanges

func (p *GDProvider) ApplyChanges(ctx context.Context, changes *plan.Changes) error

ApplyChanges applies a given set of changes in a given zone.

func (*GDProvider) Records

func (p *GDProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error)

Records returns the list of records in all relevant zones.

type Logger

type Logger interface {
	// LogRequest logs an HTTP request.
	LogRequest(*http.Request)

	// LogResponse logs an HTTP response.
	LogResponse(*http.Response)
}

Logger is the interface that should be implemented for loggers that wish to log HTTP requests and HTTP responses.

Jump to

Keyboard shortcuts

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