issue #9: Refactor recordGet to recordList for consistency across API methods, update related documentation, and revise impacted tests.

This commit is contained in:
2026-01-06 20:35:50 +01:00
parent acf2a2fc3b
commit 0f1248d08b
4 changed files with 77 additions and 91 deletions
@@ -173,21 +173,41 @@ public class CfDnsClient extends CfBasicHttpClient {
}
/**
* Retrieves all record entities for a specific second-level domain (SLD) within a given DNS
* zone.
* Retrieves DNS records for the specified second-level domain (SLD) within a zone.
*
* @param zone The DNS zone entity for which the SLD records are to be fetched.
* @param sld The second-level domain name for which the records are retrieved.
* @return A list of {@code RecordEntity} associated with the desired SLD.
* @throws CloudflareApiException If an error occurs while interacting with the Cloudflare API.
* @param zone the zone entity representing the DNS zone to query
* @param sld the second-level domain (SLD) to filter the records
* @return a list of RecordEntity objects that match the specified SLD within the zone
* @throws CloudflareNotFoundException if the specified SLD is not found in the zone
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/
public List<RecordEntity> recordList(ZoneEntity zone, String sld) throws CloudflareApiException {
return recordList(zone, sld, PagingRequest.defaultPaging());
return recordList(zone, sld, (RecordType[]) null);
}
/**
* Retrieves DNS records for the specified second-level domain (SLD) within a zone.
* Optionally filters by one or more DNS record types.
*
* @param zone The zone entity containing information about the domain zone.
* @param sld The second-level domain (SLD) for which to retrieve DNS records.
* @param types Optional parameter specifying one or more DNS record types to filter the results.
* @return A list of {@code RecordEntity} objects representing the DNS records for the specified domain.
* @throws CloudflareNotFoundException if the specified SLD is not found in the zone
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/
public List<RecordEntity> recordList(ZoneEntity zone, String sld, @Nullable RecordType... types)
throws CloudflareApiException {
String fqdn = buildFqdn(zone, sld);
String endpoint = buildEndpointWithTypeFilters(CfRequest.RECORD_INFO_NAME.buildPath(zone.getId(), fqdn), types);
RecordMultipleResponse resp = getRequest(endpoint, RecordMultipleResponse.class);
checkResponse(resp, false);
return resp.getResult();
}
/**
* Retrieves all record entities for a specific second-level domain (SLD) within a given DNS
* zone.
* zone using the provided paging request parameters.
*
* @param zone The DNS zone entity for which the SLD records are to be fetched.
* @param sld The second-level domain name for which the records are retrieved.
@@ -205,40 +225,6 @@ public class CfDnsClient extends CfBasicHttpClient {
return resp.getResult();
}
/**
* Retrieves a list of DNS record entities for a specified second-level domain (SLD)
* within a given zone.
*
* @param zone the zone entity representing the DNS zone to query
* @param sld the second-level domain (SLD) to filter the records
* @return a list of RecordEntity objects that match the specified SLD within the zone
* @throws CloudflareNotFoundException if the specified SLD is not found in the zone
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/
public List<RecordEntity> recordGet(ZoneEntity zone, String sld) throws CloudflareApiException {
return recordGet(zone, sld, (RecordType[]) null);
}
/**
* Retrieves a list of DNS records for a given second-level domain (SLD) within a specific zone.
* Optionally filters by one or more DNS record types.
*
* @param zone The zone entity containing information about the domain zone.
* @param sld The second-level domain (SLD) for which to retrieve DNS records.
* @param types Optional parameter specifying one or more DNS record types to filter the results.
* @return A list of {@code RecordEntity} objects representing the DNS records for the specified domain.
* @throws CloudflareNotFoundException if the specified SLD is not found in the zone
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/
public List<RecordEntity> recordGet(ZoneEntity zone, String sld, @Nullable RecordType... types)
throws CloudflareApiException {
String fqdn = buildFqdn(zone, sld);
String endpoint = buildEndpointWithTypeFilters(CfRequest.RECORD_INFO_NAME.buildPath(zone.getId(), fqdn), types);
RecordMultipleResponse resp = getRequest(endpoint, RecordMultipleResponse.class);
checkResponse(resp, false);
return resp.getResult();
}
/**
* Retrieves a list of all DNS records for a given zone.
* Optionally filters by one or more DNS record types.
@@ -395,7 +381,7 @@ public class CfDnsClient extends CfBasicHttpClient {
String fqdn = buildFqdn(zone, sld);
List<RecordEntity> recs;
try {
recs = recordGet(zone, sld, recordTypes);
recs = recordList(zone, sld, recordTypes);
} catch (CloudflareNotFoundException e) {
log.trace("No record of type {} found for domain {}.", recordTypes, fqdn);
return;
@@ -35,10 +35,7 @@ public class RecordOperationsImpl implements RecordOperations {
@Override
public List<RecordEntity> get() throws CloudflareApiException {
if (types == null || types.length == 0) {
return client.recordGet(zone, sld);
}
return client.recordGet(zone, sld, types);
return client.recordList(zone, sld, types);
}
@Override