Package codes.thischwa.cf
Klasse CfDnsClient
java.lang.Object
codes.thischwa.cf.CfDnsClient
CfDnsClient is a client interface to interact with Cloudflare DNS service. It allows managing DNS
records and zones within the Cloudflare system, including creating, updating, retrieving, and
deleting DNS records.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungCfDnsClient(boolean emptyResultThrowsException, String baseUrl, String authEmail, String authKey, String authToken) Constructs a new instance ofCfDnsClient, which facilitates interactions with the Cloudflare DNS API.CfDnsClient(String authEmail, String authKey, String authToken) Constructs a CfDnsClient instance for interacting with the Cloudflare DNS API.CfDnsClient(String baseUrl, String authEmail, String authKey, String authToken) Constructs a CfDnsClient instance for interacting with the Cloudflare DNS API. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected <T extends AbstractResponse>
TdeleteRequest(String endpoint, Class<T> responseType) Sends a DELETE request to the given endpoint and maps the response.protected <T extends AbstractResponse>
TgetRequest(String endpoint, Class<T> responseType) Sends a GET request to the given endpoint and maps the response.protected <T extends AbstractResponse,R extends AbstractEntity>
TpatchRequest(String endpoint, R requestPayload, Class<T> responseType) Sends a PATCH request with a payload to the given endpoint and maps the response.protected <T extends AbstractResponse,R extends AbstractEntity>
TpostRequest(String endpoint, R requestPayload, Class<T> responseType) Sends a POST request with a payload to the given endpoint and maps the response.protected <T extends AbstractResponse,R extends AbstractEntity>
TputRequest(String endpoint, R requestPayload, Class<T> responseType) Sends a PUT request with a payload to the given endpoint and maps the response.recordCreate(ZoneEntity zone, RecordEntity rec) Creates a new DNS record in the specified zone using the Cloudflare API.booleanrecordDelete(ZoneEntity zone, RecordEntity rec) Deletes a DNS record of the specified type within a given zone on the Cloudflare API.booleanrecordDelete(ZoneEntity zone, String id) Deletes a DNS record of the specified type within a given zone on the Cloudflare API.voidrecordDeleteTypeIfExists(ZoneEntity zone, String sld, RecordType type) Attempts to delete a DNS record of a specific type for a given zone and second-level domain (SLD), if it exists.recordUpdate(ZoneEntity zone, RecordEntity rec) Updates an existing DNS record in a specified Cloudflare zone.sldInfo(ZoneEntity zone, String sld, RecordType type) Retrieves detailed information about a specific second-level domain (SLD) record for a given zone and record type from the Cloudflare API.sldListAll(ZoneEntity zone, String sld) Retrieves all record entities for a specific second-level domain (SLD) within a given DNS zone.sldListAll(ZoneEntity zone, String sld, PagingRequest pagingRequest) Retrieves all record entities for a specific second-level domain (SLD) within a given DNS zone.Retrieves detailed information about a specific zone by its name.Retrieves a list of all zones from the Cloudflare API.zoneListAll(PagingRequest pagingRequest) Retrieves a list of all zones from the Cloudflare API.
-
Konstruktordetails
-
CfDnsClient
Constructs a CfDnsClient instance for interacting with the Cloudflare DNS API.- Parameter:
authEmail- The email address associated with the Cloudflare account, used for authentication.authKey- The API key of the Cloudflare account, used as part of the authentication process.authToken- The API token for accessing specific resources within the Cloudflare account.
-
CfDnsClient
Constructs a CfDnsClient instance for interacting with the Cloudflare DNS API.- Parameter:
baseUrl- The base URL of the Cloudflare API to be used for requests.authEmail- The email address associated with the Cloudflare account, used for authentication.authKey- The API key of the Cloudflare account, used as part of the authentication process.authToken- The API token for accessing specific resources within the Cloudflare account.
-
CfDnsClient
public CfDnsClient(boolean emptyResultThrowsException, String baseUrl, String authEmail, String authKey, String authToken) Constructs a new instance ofCfDnsClient, which facilitates interactions with the Cloudflare DNS API.- Parameter:
emptyResultThrowsException- Specifies if an exception should be thrown when the API response is empty. Default is true.baseUrl- The base URL for the Cloudflare API endpoint.authEmail- The email associated with the Cloudflare account for authentication.authKey- The API key for authenticating the client with Cloudflare services.authToken- The authentication token used for authorized access to Cloudflare API.
-
-
Methodendetails
-
zoneListAll
Retrieves a list of all zones from the Cloudflare API.
This method sends a GET request to the Cloudflare API endpoint for listing zones, processes the response, and returns the resulting list of ZoneEntity objects.- Gibt zurück:
- A list of ZoneEntity objects representing the zones retrieved from the Cloudflare API.
- Löst aus:
CloudflareApiException- If an error occurs during the API request or response handling.
-
zoneListAll
Retrieves a list of all zones from the Cloudflare API.
This method sends a GET request to the Cloudflare API endpoint for listing zones, processes the response, and returns the resulting list of ZoneEntity objects.- Gibt zurück:
- A list of ZoneEntity objects representing the zones retrieved from the Cloudflare API.
- Löst aus:
CloudflareApiException- If an error occurs during the API request or response handling.
-
zoneInfo
Retrieves detailed information about a specific zone by its name.- Parameter:
name- The name of the zone to retrieve information for.- Gibt zurück:
- A
ZoneEntityobject that contains details of the specified zone. - Löst aus:
CloudflareApiException- If an error occurs while making the API request or processing the response.
-
sldListAll
Retrieves all record entities for a specific second-level domain (SLD) within a given DNS zone.- Parameter:
zone- The DNS zone entity for which the SLD records are to be fetched.sld- The second-level domain name for which the records are retrieved.- Gibt zurück:
- A list of
RecordEntityobjects representing the DNS records associated with the provided SLD. - Löst aus:
CloudflareApiException- If an error occurs while interacting with the Cloudflare API.
-
sldListAll
public List<RecordEntity> sldListAll(ZoneEntity zone, String sld, PagingRequest pagingRequest) throws CloudflareApiException Retrieves all record entities for a specific second-level domain (SLD) within a given DNS zone.- Parameter:
zone- The DNS zone entity for which the SLD records are to be fetched.sld- The second-level domain name for which the records are retrieved.pagingRequest- The paging request.- Gibt zurück:
- A list of
RecordEntityobjects representing the DNS records associated with the provided SLD. - Löst aus:
CloudflareApiException- If an error occurs while interacting with the Cloudflare API.
-
sldInfo
public RecordEntity sldInfo(ZoneEntity zone, String sld, RecordType type) throws CloudflareApiException Retrieves detailed information about a specific second-level domain (SLD) record for a given zone and record type from the Cloudflare API.- Parameter:
zone- the zone entity that contains information about the DNS zonesld- the second-level domain (SLD) for which the record information is requestedtype- the type of DNS record (e.g., A, AAAA, CNAME) being queried- Gibt zurück:
- the record entity containing detailed information about the requested SLD and record type
- Löst aus:
CloudflareApiException- if an error occurs during interaction with the Cloudflare API
-
recordCreate
Creates a new DNS record in the specified zone using the Cloudflare API.- Parameter:
zone- The zone entity where the record will be created. Contains details such as zone ID.rec- The record entity representing the DNS record to be created, including its attributes.- Gibt zurück:
- The created record entity as returned by the Cloudflare API.
- Löst aus:
CloudflareApiException- If an error occurs while interacting with the Cloudflare API.
-
recordDelete
Deletes a DNS record of the specified type within a given zone on the Cloudflare API.- Parameter:
zone- The zone entity that specifies the zone in which the record exists.rec- The record entity that represents the DNS record to be deleted.- Gibt zurück:
trueif the DNS record was successfully deleted;falseotherwise.- Löst aus:
CloudflareApiException- if there is an issue during the API communication or the request fails for any reason.
-
recordDelete
Deletes a DNS record of the specified type within a given zone on the Cloudflare API.- Parameter:
zone- The zone entity that specifies the zone in which the record exists.id- The record entity that represents the DNS record to be deleted.- Gibt zurück:
trueif the DNS record was successfully deleted;falseotherwise.- Löst aus:
CloudflareApiException- if there is an issue during the API communication or the request fails for any reason.
-
recordUpdate
Updates an existing DNS record in a specified Cloudflare zone.- Parameter:
zone- the zone entity containing the ID of the target zonerec- the record entity containing the ID of the DNS record to be updated and its updated data- Gibt zurück:
- the updated record entity as returned by the Cloudflare API
- Löst aus:
CloudflareApiException- if an error occurs while interacting with the Cloudflare API
-
recordDeleteTypeIfExists
public void recordDeleteTypeIfExists(ZoneEntity zone, String sld, RecordType type) throws CloudflareApiException Attempts to delete a DNS record of a specific type for a given zone and second-level domain (SLD), if it exists.- Parameter:
zone- The zone in which the DNS record resides. It provides information about the domain.sld- The second-level domain (SLD) of the fully qualified domain name (FQDN) for which the record is being deleted.type- The type of the DNS record to be deleted (e.g., A, CNAME, TXT).- Löst aus:
CloudflareApiException- If an error occurs while interacting with the Cloudflare API.
-
getRequest
protected <T extends AbstractResponse> T getRequest(String endpoint, Class<T> responseType) throws CloudflareApiException Sends a GET request to the given endpoint and maps the response.- Löst aus:
CloudflareApiException
-
deleteRequest
protected <T extends AbstractResponse> T deleteRequest(String endpoint, Class<T> responseType) throws CloudflareApiException Sends a DELETE request to the given endpoint and maps the response.- Löst aus:
CloudflareApiException
-
postRequest
protected <T extends AbstractResponse,R extends AbstractEntity> T postRequest(String endpoint, R requestPayload, Class<T> responseType) throws CloudflareApiException Sends a POST request with a payload to the given endpoint and maps the response.- Löst aus:
CloudflareApiException
-
putRequest
protected <T extends AbstractResponse,R extends AbstractEntity> T putRequest(String endpoint, R requestPayload, Class<T> responseType) throws CloudflareApiException Sends a PUT request with a payload to the given endpoint and maps the response.- Löst aus:
CloudflareApiException
-
patchRequest
protected <T extends AbstractResponse,R extends AbstractEntity> T patchRequest(String endpoint, R requestPayload, Class<T> responseType) throws CloudflareApiException Sends a PATCH request with a payload to the given endpoint and maps the response.- Löst aus:
CloudflareApiException
-