Files
dns-keeper/src/gandi.h
T

48 lines
1.3 KiB
C

#ifndef GANDI_H
#define GANDI_H
#define GANDI_MAX_IP_LEN 46
/*
* Stores the API key internally.
* Must be called once at startup before calling other gandi methods.
*
* Returns 0 on success.
* Returns -1 if api_key is NULL or empty.
*/
int gandi_init(const char *api_key);
/*
* Fetches the current IPv4 addr from the special gandi fqdn
*
* Returns 0 on success.
* Returns -1 on network or curl error.
* Returns -2 on API auth error (401/403).
* Returns -3 if the record was not found or has no values.
*/
int gandi_get_self_ip(const char *domain, const char *record_name, char *out_ip);
/*
* Fetches all records of all domains,
* looks for all A records where rrset_value
* is set to `old_ip` and patches each one to `new_ip`.
*
* Returns 0 on success (all records updated).
* Returns -1 on network or curl error, or if any patch failed.
* Returns -2 on API auth error (401/403).
* Returns -3 if no A records had old_ip.
*/
int gandi_update_domains(const char *fqdn, const char *old_ip, const char *new_ip);
/*
* Patches an A record's rrset_value from `old_ip` to `new_ip`.
*
* Returns 0 on success.
* Returns -1 on network or curl error.
* Returns -2 on API auth error (401/403).
*/
int gandi_update_record(const char *domain, const char *record_name,
const char *old_ip, const char *new_ip);
#endif /* GANDI_H */