update README and fix "getRecord" wording in docs and messages
Build and Analyse / build-and-analyse (push) Successful in 24s

- README: fix fluent API examples (getRecord), complete recordCreate
  docs, document paging, groupRecordsByFqdn, recordDelete by id and
  multiple types in recordDeleteTypeIfExists, mention Java 17
- replace stray "getRecord" wording with "record" in javadoc, log and
  exception messages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
thischwaandClaude Opus 5.5 committed 2026-10-31 12:25:27 +01:00
1 parent d2acc3ce74
commit 31229ff627
15 files changed
+202 -162

No files matched your search

+59 -21
View File
@@ -22,6 +22,8 @@ This guide comes without any warranty. Use at your own risk. The author is not r
## Get It ## Get It
Java 17 or higher is required.
The project has its own maven repository. Follow the instructions on the latest [package](https://git.mein-gateway.de/thischwa/-/packages/maven/codes.thischwa:cloudflaredns) to add the repository to your project. The project has its own maven repository. Follow the instructions on the latest [package](https://git.mein-gateway.de/thischwa/-/packages/maven/codes.thischwa:cloudflaredns) to add the repository to your project.
## Changelog ## Changelog
@@ -33,7 +35,7 @@ See [changelog](changelog.md)
The methods can be categorized as follows: The methods can be categorized as follows:
- `Zone`: list, info - `Zone`: list, info
- `Record`: list, info, create, update, delete - `Record`: list, info, create, update, delete, batch
The API provides two styles for working with DNS records: The API provides two styles for working with DNS records:
@@ -71,6 +73,12 @@ List<ZoneEntity> zones = cfDnsClient.zoneList();
zones.forEach(zone -> System.out.println("Zone: " + zone.getName())); zones.forEach(zone -> System.out.println("Zone: " + zone.getName()));
``` ```
By default, up to 1000 zones are fetched in a single request. Use a `PagingRequest` to control paging:
```java
List<ZoneEntity> zones = cfDnsClient.zoneList(PagingRequest.of(1, 50)); // page 1, 50 zones per page
```
--- ---
### `zoneGet` ### `zoneGet`
@@ -129,23 +137,47 @@ List<RecordEntity> allZoneRecords = cfDnsClient.recordList(zone);
// Get only A and AAAA records of a zone // Get only A and AAAA records of a zone
List<RecordEntity> ipZoneRecords = cfDnsClient.recordList(zone, RecordType.A, RecordType.AAAA); List<RecordEntity> ipZoneRecords = cfDnsClient.recordList(zone, RecordType.A, RecordType.AAAA);
// Get the records of a zone page by page (page 2, 100 records per page)
List<RecordEntity> pagedRecords = cfDnsClient.recordList(zone, PagingRequest.of(2, 100));
``` ```
Without a `PagingRequest`, up to 1000 records are fetched in a single request.
#### Group by FQDN
The static helper `CfDnsClient.groupRecordsByFqdn` groups a list of records by their fully qualified domain name:
```java
Map<String, List<RecordEntity>> byFqdn = CfDnsClient.groupRecordsByFqdn(cfDnsClient.recordList(zone));
```
--- ---
### `recordCreate` ### `recordCreateSld` / `recordCreate`
Create a new DNS record in a specific zone. Create a new DNS record in a specific zone.
- **Parameters**: - **Parameters**:
- `ZoneEntity zone` - DNS zone object. - `ZoneEntity zone` - The DNS zone object.
- `String sld` - The sub-tld of the new record. - `String sld` - The second-level domain of the new record (e.g., "api" in "api.example.com").
- `int ttl` - The time-to-live in seconds of the new rcord. - `int ttl` - The time-to-live in seconds of the new record.
- `RecordType type` - The record type (e.g., A, AAAA, CNAME).
- `String content` - The content of the record (e.g., the IP address of an A record).
- **Returns**: The created `RecordEntity`.
```java ```java
RecordEntity created = client.recordCreateSld(zone, "api", 60, RecordType.A, "192.168.1.1"); RecordEntity created = cfDnsClient.recordCreateSld(zone, "api", 60, RecordType.A, "192.168.1.1");
System.out.println("Created Record ID: " + created.getId()); System.out.println("Created Record ID: " + created.getId());
``` ```
Alternatively, the record can be created with its fully qualified name or from a `RecordEntity`:
```java
cfDnsClient.recordCreate(zone, "api.example.com", 60, RecordType.A, "192.168.1.1");
cfDnsClient.recordCreate(zone, RecordEntity.build("api.example.com", RecordType.A, 60, "192.168.1.1"));
```
--- ---
### `recordUpdate` ### `recordUpdate`
@@ -177,19 +209,25 @@ boolean isDeleted = cfDnsClient.recordDelete(zone, record);
System.out.println(isDeleted ? "Deletion successful." : "Deletion failed."); System.out.println(isDeleted ? "Deletion successful." : "Deletion failed.");
``` ```
If only the ID is known, the record can be deleted by its ID:
```java
cfDnsClient.recordDelete(zone, record.getId());
```
--- ---
### `recordDeleteTypeIfExists` ### `recordDeleteTypeIfExists`
Delete a DNS record of a specific type if it exists. Delete the DNS records of the given types if they exist.
- **Parameters**: - **Parameters**:
- `ZoneEntity zone` - Target zone. - `ZoneEntity zone` - Target zone.
- `String sld` - Second-level domain. - `String sld` - Second-level domain.
- `RecordType type` - Record type. - `RecordType... types` - One or more record types.
```java ```java
cfDnsClient.recordDeleteTypeIfExists(zone, "api", RecordType.A); cfDnsClient.recordDeleteTypeIfExists(zone, "api", RecordType.A, RecordType.AAAA);
System.out.println("Deletion attempt completed."); System.out.println("Deletion attempt completed.");
``` ```
@@ -320,28 +358,28 @@ that reduces verbosity and improves code readability.
### Basic Usage ### Basic Usage
```java ```java
// Create a DNS getRecord // Create a DNS record
client.zone("example.com") client.zone("example.com")
.record("api") .getRecord("api")
.create(RecordType.A, "192.168.1.1",60); .create(RecordType.A, "192.168.1.1",60);
// Get DNS records of a subdomain // Get DNS records of a subdomain
List<RecordEntity> records = client.zone("example.com") List<RecordEntity> records = client.zone("example.com")
.record("www", RecordType.A) .getRecord("www", RecordType.A)
.get(); .get();
// Get all DNS records of a zone // Get all DNS records of a zone
List<RecordEntity> zoneRecords = client.zone("example.com") List<RecordEntity> zoneRecords = client.zone("example.com")
.list(RecordType.A, RecordType.AAAA); .list(RecordType.A, RecordType.AAAA);
// Update a DNS getRecord // Update a DNS record
RecordEntity updated = client.zone("example.com") RecordEntity updated = client.zone("example.com")
.record("api", RecordType.A) .getRecord("api", RecordType.A)
.update("192.168.1.2"); .update("192.168.1.2");
// Delete DNS records // Delete DNS records
client.zone("example.com") client.zone("example.com")
.record("old-service") .getRecord("old-service")
.delete(RecordType.A, RecordType.AAAA); .delete(RecordType.A, RecordType.AAAA);
``` ```
@@ -359,25 +397,25 @@ CfDnsClient client = new CfDnsClientBuilder()
.withApiTokenAuth("your-api-token") .withApiTokenAuth("your-api-token")
.build(); .build();
// Create a new getRecord // Create a new record
client.zone("example.com") client.zone("example.com")
.record("api") .getRecord("api")
.create(RecordType.A, "192.168.100.1",60); .create(RecordType.A, "192.168.100.1",60);
// Retrieve and verify // Retrieve and verify
List<RecordEntity> records = client.zone("example.com") List<RecordEntity> records = client.zone("example.com")
.record("api", RecordType.A) .getRecord("api", RecordType.A)
.get(); .get();
System.out.println("IP: "+records.get(0).getContent()); System.out.println("IP: "+records.get(0).getContent());
// Update the getRecord // Update the record
client.zone("example.com") client.zone("example.com")
.record("api",RecordType.A) .getRecord("api",RecordType.A)
.update("192.168.100.2"); .update("192.168.100.2");
// Clean up // Clean up
client.zone("example.com") client.zone("example.com")
.record("api") .getRecord("api")
.delete(RecordType.A); .delete(RecordType.A);
``` ```
+2
View File
@@ -3,6 +3,8 @@
- 0.6.0-SNAPSHOT: - 0.6.0-SNAPSHOT:
- updated dependencies: jackson 3.2.4, httpclient5 5.6.4, lombok 1.18.48, logback-classic 1.6.6, mockito-junit-jupiter 5.24.0 - updated dependencies: jackson 3.2.4, httpclient5 5.6.4, lombok 1.18.48, logback-classic 1.6.6, mockito-junit-jupiter 5.24.0
- updated maven plugins: maven-compiler-plugin 3.16.0, maven-surefire-plugin 3.6.0, maven-jar-plugin 3.5.1 - updated maven plugins: maven-compiler-plugin 3.16.0, maven-surefire-plugin 3.6.0, maven-jar-plugin 3.5.1
- README: fixed fluent API examples, documented paging and further methods
- fixed "getRecord" wording in javadoc, log and exception messages (e.g. "Invalid record type")
- 0.5.0: - 0.5.0:
- moved the project to git.mein-gateway.de - moved the project to git.mein-gateway.de
- replaced sonarqube with own actions - replaced sonarqube with own actions
@@ -219,11 +219,11 @@ public class CfDnsClient extends CfBasicHttpClient {
/** /**
* Retrieves DNS records for the specified second-level domain (SLD) within a zone. * Retrieves DNS records for the specified second-level domain (SLD) within a zone.
* Optionally, filters by one or more DNS getRecord types. * Optionally, filters by one or more DNS record types.
* *
* @param zone The zone entity containing information about the domain zone. * @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 sld The second-level domain (SLD) for which to retrieve DNS records.
* @param types Optional parameter specifying one or more DNS getRecord types to filter the results. * @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. * @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 CloudflareNotFoundException if the specified SLD is not found in the zone
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API * @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
@@ -240,10 +240,10 @@ public class CfDnsClient extends CfBasicHttpClient {
/** /**
* Retrieves a list of all DNS records for a given zone. * Retrieves a list of all DNS records for a given zone.
* Optionally, filters by one or more DNS getRecord types. * Optionally, filters by one or more DNS record types.
* *
* @param zone The zone entity containing information about the domain zone. * @param zone The zone entity containing information about the domain zone.
* @param types Optional parameter specifying one or more DNS getRecord types to filter the results. * @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 zone. * @return A list of {@code RecordEntity} objects representing the DNS records for the specified zone.
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API * @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/ */
@@ -257,17 +257,17 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a new DNS getRecord for a given second-level domain (SLD) within the specified zone. * Creates a new DNS record for a given second-level domain (SLD) within the specified zone.
* *
* @param zone The ZoneEntity representing the DNS zone where the getRecord is to be created. * @param zone The ZoneEntity representing the DNS zone where the record is to be created.
* @param sld The second-level domain (SLD) for which the DNS getRecord is being created. * @param sld The second-level domain (SLD) for which the DNS record is being created.
* @param ttl The time-to-live (TTL) value for the DNS getRecord in seconds. * @param ttl The time-to-live (TTL) value for the DNS record in seconds.
* @param type The RecordType specifying the type of the DNS getRecord (e.g., A, AAAA, CNAME). * @param type The RecordType specifying the type of the DNS record (e.g., A, AAAA, CNAME).
* @param content The content of the DNS getRecord (e.g., IP address for A/AAAA records, target * @param content The content of the DNS record (e.g., IP address for A/AAAA records, target
* domain for CNAME). * domain for CNAME).
* @return The created RecordEntity object containing details of the newly created DNS getRecord. * @return The created RecordEntity object containing details of the newly created DNS record.
* @throws CloudflareApiException If an error occurs while communicating with the Cloudflare API * @throws CloudflareApiException If an error occurs while communicating with the Cloudflare API
* or creating the getRecord. * or creating the record.
*/ */
public RecordEntity recordCreateSld(ZoneEntity zone, String sld, int ttl, RecordType type, public RecordEntity recordCreateSld(ZoneEntity zone, String sld, int ttl, RecordType type,
String content) throws CloudflareApiException { String content) throws CloudflareApiException {
@@ -276,14 +276,14 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a DNS getRecord in the specified DNS zone with the provided details. * Creates a DNS record in the specified DNS zone with the provided details.
* *
* @param zone the DNS zone in which the getRecord will be created * @param zone the DNS zone in which the record will be created
* @param name the name of the DNS getRecord (e.g., www.example.com) * @param name the name of the DNS record (e.g., www.example.com)
* @param ttl the time-to-live (TTL) value for the DNS getRecord * @param ttl the time-to-live (TTL) value for the DNS record
* @param type the type of the DNS getRecord (e.g., A, AAAA, CNAME) * @param type the type of the DNS record (e.g., A, AAAA, CNAME)
* @param content the content or value of the DNS getRecord * @param content the content or value of the DNS record
* @return the created DNS getRecord as a {@link RecordEntity} object * @return the created DNS record as a {@link RecordEntity} object
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API * @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/ */
public RecordEntity recordCreate(ZoneEntity zone, String name, int ttl, RecordType type, public RecordEntity recordCreate(ZoneEntity zone, String name, int ttl, RecordType type,
@@ -293,13 +293,13 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a new DNS getRecord in the specified zone using the Cloudflare API. * Creates a new DNS record in the specified zone using the Cloudflare API.
* *
* @param zone The zone entity where the getRecord will be created. Contains details such as zone * @param zone The zone entity where the record will be created. Contains details such as zone
* ID. * ID.
* @param rec The getRecord entity representing the DNS getRecord to be created, including its * @param rec The record entity representing the DNS record to be created, including its
* attributes. * attributes.
* @return The created getRecord entity as returned by the Cloudflare API. * @return The created record entity as returned by the Cloudflare API.
* @throws CloudflareApiException If an error occurs while interacting with the Cloudflare API. * @throws CloudflareApiException If an error occurs while interacting with the Cloudflare API.
*/ */
public RecordEntity recordCreate(ZoneEntity zone, RecordEntity rec) public RecordEntity recordCreate(ZoneEntity zone, RecordEntity rec)
@@ -314,11 +314,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes a DNS getRecord of the specified type within a given zone on the Cloudflare API. * Deletes a DNS record of the specified type within a given zone on the Cloudflare API.
* *
* @param zone The zone entity that specifies the zone in which the getRecord exists. * @param zone The zone entity that specifies the zone in which the record exists.
* @param rec The getRecord entity that represents the DNS getRecord to be deleted. * @param rec The record entity that represents the DNS record to be deleted.
* @return {@code true} if the DNS getRecord was successfully deleted; {@code false} otherwise. * @return {@code true} if the DNS record was successfully deleted; {@code false} otherwise.
* @throws CloudflareApiException if there is an issue during the API communication, or the * @throws CloudflareApiException if there is an issue during the API communication, or the
* request fails for any reason. * request fails for any reason.
*/ */
@@ -333,11 +333,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes a DNS getRecord of the specified type within a given zone on the Cloudflare API. * Deletes a DNS record of the specified type within a given zone on the Cloudflare API.
* *
* @param zone The zone entity that specifies the zone in which the getRecord exists. * @param zone The zone entity that specifies the zone in which the record exists.
* @param id The getRecord entity that represents the DNS getRecord to be deleted. * @param id The record entity that represents the DNS record to be deleted.
* @return {@code true} if the DNS getRecord was successfully deleted; {@code false} otherwise. * @return {@code true} if the DNS record was successfully deleted; {@code false} otherwise.
* @throws CloudflareApiException if there is an issue during the API communication or the request * @throws CloudflareApiException if there is an issue during the API communication or the request
* fails for any reason. * fails for any reason.
*/ */
@@ -350,12 +350,12 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Updates an existing DNS getRecord in a specified Cloudflare zone. * Updates an existing DNS record in a specified Cloudflare zone.
* *
* @param zone the zone entity containing the ID of the target zone * @param zone the zone entity containing the ID of the target zone
* @param rec the getRecord entity containing the ID of the DNS getRecord to be updated and its updated * @param rec the record entity containing the ID of the DNS record to be updated and its updated
* data * data
* @return the updated getRecord entity as returned by the Cloudflare API * @return the updated record entity as returned by the Cloudflare API
* @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API * @throws CloudflareApiException if an error occurs while interacting with the Cloudflare API
*/ */
public RecordEntity recordUpdate(ZoneEntity zone, RecordEntity rec) public RecordEntity recordUpdate(ZoneEntity zone, RecordEntity rec)
@@ -371,11 +371,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes DNS records of a specific type within a given zone if they exist. If no getRecord of the * Deletes DNS records of a specific type within a given zone if they exist. If no record of the
* specified type exists, it logs this occurrence without throwing an exception. * specified type exists, it logs this occurrence without throwing an exception.
* *
* @param zone The DNS zone entity in which the getRecord exists. * @param zone The DNS zone entity in which the record exists.
* @param sld The second-level domain for which the getRecord is being checked. * @param sld The second-level domain for which the record is being checked.
* @param recordTypes The types of DNS records that should be deleted if they exist. * @param recordTypes The types of DNS records that should be deleted if they exist.
* @throws CloudflareApiException If an error occurs during API communication. * @throws CloudflareApiException If an error occurs during API communication.
*/ */
@@ -386,7 +386,7 @@ public class CfDnsClient extends CfBasicHttpClient {
try { try {
recs = recordList(zone, sld, recordTypes); recs = recordList(zone, sld, recordTypes);
} catch (CloudflareNotFoundException e) { } catch (CloudflareNotFoundException e) {
log.trace("No getRecord of type {} found for domain {}.", recordTypes, fqdn); log.trace("No record of type {} found for domain {}.", recordTypes, fqdn);
return; return;
} }
for (RecordEntity rec : recs) { for (RecordEntity rec : recs) {
@@ -394,13 +394,13 @@ public class CfDnsClient extends CfBasicHttpClient {
recordDelete(zone, rec); recordDelete(zone, rec);
log.info("Record {} of type {} successful deleted.", fqdn, recordTypes); log.info("Record {} of type {} successful deleted.", fqdn, recordTypes);
} catch (CloudflareApiException e) { } catch (CloudflareApiException e) {
log.error("Failed to delete getRecord {} of type {} for zone {}: {}", fqdn, recordTypes, zone.getName(), e.getMessage()); log.error("Failed to delete record {} of type {} for zone {}: {}", fqdn, recordTypes, zone.getName(), e.getMessage());
} }
} }
} }
/** /**
* Processes a batch of DNS getRecord operations (POST, PUT, PATCH, DELETE) for a specified zone. * Processes a batch of DNS record operations (POST, PUT, PATCH, DELETE) for a specified zone.
* This method builds and cleans the input records, sends the batch request to the Cloudflare API, * This method builds and cleans the input records, sends the batch request to the Cloudflare API,
* and returns a result containing processed batch entries. * and returns a result containing processed batch entries.
* *
@@ -416,7 +416,7 @@ public class CfDnsClient extends CfBasicHttpClient {
@Nullable List<RecordEntity> patchRecords, @Nullable List<RecordEntity> deleteRecords) @Nullable List<RecordEntity> patchRecords, @Nullable List<RecordEntity> deleteRecords)
throws CloudflareApiException { throws CloudflareApiException {
BatchEntry batchEntry = new BatchEntry(); BatchEntry batchEntry = new BatchEntry();
// build 'clean' getRecord entries // build 'clean' record entries
if (postRecords != null) { if (postRecords != null) {
batchEntry.setPosts(cleanRecordsForPostOrPut(postRecords)); batchEntry.setPosts(cleanRecordsForPostOrPut(postRecords));
} }
@@ -27,20 +27,20 @@ public enum CfRequest {
*/ */
RECORD_LIST("/zones/%s/dns_records"), RECORD_LIST("/zones/%s/dns_records"),
/** /**
* Represents the API endpoint path for retrieving information about a DNS getRecord within a * Represents the API endpoint path for retrieving information about a DNS record within a
* specific DNS zone by its name. The endpoint path includes placeholders for the zone identifier * specific DNS zone by its name. The endpoint path includes placeholders for the zone identifier
* and the getRecord name, which need to be provided to construct the complete path. * and the record name, which need to be provided to construct the complete path.
*/ */
RECORD_LIST_NAME("/zones/%s/dns_records?name=%s"), RECORD_LIST_NAME("/zones/%s/dns_records?name=%s"),
/** /**
* Represents the API endpoint path for creating a new DNS getRecord within a specific DNS zone. The * Represents the API endpoint path for creating a new DNS record within a specific DNS zone. The
* endpoint path includes a placeholder for the zone identifier, which needs to be provided to * endpoint path includes a placeholder for the zone identifier, which needs to be provided to
* construct the complete path. * construct the complete path.
*/ */
RECORD_CREATE("/zones/%s/dns_records"), RECORD_CREATE("/zones/%s/dns_records"),
/** /**
* Represents the API endpoint path for updating an existing DNS getRecord within a specific DNS * Represents the API endpoint path for updating an existing DNS record within a specific DNS
* zone. The endpoint path includes placeholders for the zone identifier and the getRecord * zone. The endpoint path includes placeholders for the zone identifier and the record
* identifier, which need to be provided to construct the complete path. * identifier, which need to be provided to construct the complete path.
*/ */
RECORD_UPDATE("/zones/%s/dns_records/%s"), RECORD_UPDATE("/zones/%s/dns_records/%s"),
@@ -51,8 +51,8 @@ public enum CfRequest {
*/ */
RECORD_BATCH("/zones/%s/dns_records/batch"), RECORD_BATCH("/zones/%s/dns_records/batch"),
/** /**
* Represents the API endpoint path for deleting an existing DNS getRecord within a specific DNS * Represents the API endpoint path for deleting an existing DNS record within a specific DNS
* zone. The endpoint path includes placeholders for the zone identifier and the getRecord * zone. The endpoint path includes placeholders for the zone identifier and the record
* identifier, which need to be provided to construct the complete path. * identifier, which need to be provided to construct the complete path.
*/ */
RECORD_DELETE("/zones/%s/dns_records/%s"); RECORD_DELETE("/zones/%s/dns_records/%s");
@@ -6,7 +6,7 @@ import codes.thischwa.cf.model.RecordType;
import java.util.List; import java.util.List;
/** /**
* Fluent interface for getRecord-level operations. * Fluent interface for record-level operations.
* Provides a chainable API for CRUD operations on DNS records. * Provides a chainable API for CRUD operations on DNS records.
*/ */
public interface RecordOperations { public interface RecordOperations {
@@ -20,29 +20,29 @@ public interface RecordOperations {
List<RecordEntity> get() throws CloudflareApiException; List<RecordEntity> get() throws CloudflareApiException;
/** /**
* Creates a new DNS getRecord with the specified parameters. * Creates a new DNS record with the specified parameters.
* *
* @param type the DNS getRecord type (e.g., A, AAAA, CNAME) * @param type the DNS record type (e.g., A, AAAA, CNAME)
* @param content the content of the DNS getRecord (e.g., IP address) * @param content the content of the DNS record (e.g., IP address)
* @param ttl the time-to-live value in seconds * @param ttl the time-to-live value in seconds
* @return the created RecordEntity * @return the created RecordEntity
* @throws CloudflareApiException if an error occurs while creating the getRecord * @throws CloudflareApiException if an error occurs while creating the record
*/ */
RecordEntity create(RecordType type, String content, int ttl) throws CloudflareApiException; RecordEntity create(RecordType type, String content, int ttl) throws CloudflareApiException;
/** /**
* Updates an existing DNS getRecord with new content. * Updates an existing DNS record with new content.
* *
* @param newContent the new content for the DNS getRecord * @param newContent the new content for the DNS record
* @return the updated RecordEntity * @return the updated RecordEntity
* @throws CloudflareApiException if an error occurs while updating the getRecord * @throws CloudflareApiException if an error occurs while updating the record
*/ */
RecordEntity update(String newContent) throws CloudflareApiException; RecordEntity update(String newContent) throws CloudflareApiException;
/** /**
* Deletes DNS records of the specified types. * Deletes DNS records of the specified types.
* *
* @param types the DNS getRecord types to delete * @param types the DNS record types to delete
* @throws CloudflareApiException if an error occurs while deleting records * @throws CloudflareApiException if an error occurs while deleting records
*/ */
void delete(RecordType... types) throws CloudflareApiException; void delete(RecordType... types) throws CloudflareApiException;
@@ -9,7 +9,7 @@ import java.util.List;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Implementation of RecordOperations for fluent API access to getRecord-level operations. * Implementation of RecordOperations for fluent API access to record-level operations.
*/ */
public class RecordOperationsImpl implements RecordOperations { public class RecordOperationsImpl implements RecordOperations {
@@ -6,7 +6,7 @@
* *
* <p>Example usage: * <p>Example usage:
* <pre><code> * <pre><code>
* // Create a DNS getRecord * // Create a DNS record
* client.zone("example.com") * client.zone("example.com")
* .getRecord("api") * .getRecord("api")
* .create(RecordType.A, "192.168.1.1", 60); * .create(RecordType.A, "192.168.1.1", 60);
@@ -16,7 +16,7 @@
* .getRecord("www", RecordType.A) * .getRecord("www", RecordType.A)
* .get(); * .get();
* *
* // Update a DNS getRecord * // Update a DNS record
* client.zone("example.com") * client.zone("example.com")
* .getRecord("api", RecordType.A) * .getRecord("api", RecordType.A)
* .update("192.168.1.2"); * .update("192.168.1.2");
@@ -5,11 +5,11 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/** /**
* Represents a batch entry containing different types of operations on getRecord entities. * Represents a batch entry containing different types of operations on record entities.
* *
* <p>A BatchEntry groups together collections of operations (patches, posts, puts, and deletes) * <p>A BatchEntry groups together collections of operations (patches, posts, puts, and deletes)
* intended to be performed as part of a single batch process. Each operation corresponds to a specific * intended to be performed as part of a single batch process. Each operation corresponds to a specific
* type of action on DNS getRecord entities. * type of action on DNS record entities.
* *
* <ul> * <ul>
* <li><b>patches</b>: A list of {@link RecordEntity} objects representing partial updates to existing records. * <li><b>patches</b>: A list of {@link RecordEntity} objects representing partial updates to existing records.
@@ -5,7 +5,7 @@ package codes.thischwa.cf.model;
* *
* <p>This class is used for API responses where the primary result is a batch entry, * <p>This class is used for API responses where the primary result is a batch entry,
* which includes collections of operations such as patches, posts, puts, and deletes * which includes collections of operations such as patches, posts, puts, and deletes
* performed on DNS getRecord entities. * performed on DNS record entities.
* *
* <p>Extends {@code AbstractSingleResponse} with {@code BatchEntry} as the generic type, * <p>Extends {@code AbstractSingleResponse} with {@code BatchEntry} as the generic type,
* ensuring that the response result is a batch of operations. * ensuring that the response result is a batch of operations.
@@ -6,22 +6,22 @@ import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Represents a DNS getRecord entity within a specific zone. * Represents a DNS record entity within a specific zone.
* *
* <p>Attributes defined in this class include: * <p>Attributes defined in this class include:
* *
* <ul> * <ul>
* <li>DNS getRecord type such as "A" or "CNAME". * <li>DNS record type such as "A" or "CNAME".
* <li>Name of the DNS getRecord. * <li>Name of the DNS record.
* <li>Content of the DNS getRecord, such as an IP address. * <li>Content of the DNS record, such as an IP address.
* <li>Flags indicating whether the getRecord is proxiable or proxied. * <li>Flags indicating whether the record is proxiable or proxied.
* <li>TTL (Time-To-Live) for the DNS getRecord. * <li>TTL (Time-To-Live) for the DNS record.
* <li>A locked status to indicate the immutability of the getRecord. * <li>A locked status to indicate the immutability of the record.
* <li>Zone-specific metadata including zone ID and name. * <li>Zone-specific metadata including zone ID and name.
* <li>Timestamps for creation and modification. * <li>Timestamps for creation and modification.
* </ul> * </ul>
* *
* <p>Provides a static factory method {@code build} for creating a DNS getRecord with specific * <p>Provides a static factory method {@code build} for creating a DNS record with specific
* attributes. * attributes.
*/ */
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@@ -45,7 +45,7 @@ public class RecordEntity extends AbstractEntity {
/** /**
* Initializes a new instance of the RecordEntity class and invokes the parent constructor from * Initializes a new instance of the RecordEntity class and invokes the parent constructor from
* the AbstractEntity class. The RecordEntity class represents a DNS getRecord entity within a * the AbstractEntity class. The RecordEntity class represents a DNS record entity within a
* specific zone, encapsulating attributes such as type, name, content, TTL, and other related * specific zone, encapsulating attributes such as type, name, content, TTL, and other related
* metadata. * metadata.
*/ */
@@ -56,10 +56,10 @@ public class RecordEntity extends AbstractEntity {
/** /**
* Builds and returns a {@link RecordEntity} instance with the specified attributes. * Builds and returns a {@link RecordEntity} instance with the specified attributes.
* *
* @param name the name of the DNS getRecord * @param name the name of the DNS record
* @param type the {@link RecordType} of the DNS getRecord * @param type the {@link RecordType} of the DNS record
* @param ttl the time-to-live (TTL) value for the DNS getRecord * @param ttl the time-to-live (TTL) value for the DNS record
* @param content the content of the DNS getRecord, typically an IP address * @param content the content of the DNS record, typically an IP address
* @return a {@link RecordEntity} populated with the provided attributes * @return a {@link RecordEntity} populated with the provided attributes
*/ */
public static RecordEntity build(String name, RecordType type, Integer ttl, String content) { public static RecordEntity build(String name, RecordType type, Integer ttl, String content) {
@@ -74,8 +74,8 @@ public class RecordEntity extends AbstractEntity {
/** /**
* Builds and returns a {@link RecordEntity} instance with the specified ID and content. * Builds and returns a {@link RecordEntity} instance with the specified ID and content.
* *
* @param id the unique identifier for the DNS getRecord * @param id the unique identifier for the DNS record
* @param content the content of the DNS getRecord, typically an IP address or other getRecord data * @param content the content of the DNS record, typically an IP address or other record data
* @return a {@link RecordEntity} populated with the provided ID and content * @return a {@link RecordEntity} populated with the provided ID and content
*/ */
public static RecordEntity build(String id, String content) { public static RecordEntity build(String id, String content) {
@@ -88,11 +88,11 @@ public class RecordEntity extends AbstractEntity {
/** /**
* Builds and returns a {@link RecordEntity} instance with the specified attributes. * Builds and returns a {@link RecordEntity} instance with the specified attributes.
* *
* @param id the unique identifier for the DNS getRecord * @param id the unique identifier for the DNS record
* @param name the name of the DNS getRecord * @param name the name of the DNS record
* @param type the type of the DNS getRecord, represented as a string (e.g., "A", "CNAME") * @param type the type of the DNS record, represented as a string (e.g., "A", "CNAME")
* @param ttl the time-to-live (TTL) value for the DNS getRecord * @param ttl the time-to-live (TTL) value for the DNS record
* @param content the content of the DNS getRecord, typically an IP address or other getRecord data * @param content the content of the DNS record, typically an IP address or other record data
* @return a {@link RecordEntity} populated with the provided attributes * @return a {@link RecordEntity} populated with the provided attributes
* @throws IllegalArgumentException if the type string is not a valid RecordType * @throws IllegalArgumentException if the type string is not a valid RecordType
*/ */
@@ -101,7 +101,7 @@ public class RecordEntity extends AbstractEntity {
try { try {
recordType = RecordType.valueOf(type); recordType = RecordType.valueOf(type);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid getRecord type: " + type + ". Must be one of: " throw new IllegalArgumentException("Invalid record type: " + type + ". Must be one of: "
+ java.util.Arrays.toString(RecordType.values()), e); + java.util.Arrays.toString(RecordType.values()), e);
} }
RecordEntity rec = new RecordEntity(); RecordEntity rec = new RecordEntity();
@@ -114,11 +114,11 @@ public class RecordEntity extends AbstractEntity {
} }
/** /**
* Retrieves the short name (subdomain) of the DNS getRecord. * Retrieves the short name (subdomain) of the DNS record.
* If the name contains a dot ('.'), only the substring before the first dot is returned. * If the name contains a dot ('.'), only the substring before the first dot is returned.
* This is useful for getting the subdomain part of a fully qualified domain name. * This is useful for getting the subdomain part of a fully qualified domain name.
* *
* @return the short name of the DNS getRecord (substring before the first dot), * @return the short name of the DNS record (substring before the first dot),
* or the full name if no dot is present * or the full name if no dot is present
*/ */
public String getSld() { public String getSld() {
@@ -9,7 +9,7 @@ public class RecordMultipleResponse extends AbstractMultipleResponse<RecordEntit
/** /**
* Constructs an instance of RecordMultipleResponse. * Constructs an instance of RecordMultipleResponse.
* *
* <p>This class represents a response containing multiple DNS getRecord entities from the * <p>This class represents a response containing multiple DNS record entities from the
* Cloudflare API. It inherits functionality from AbstractMultipleResponse to handle multiple * Cloudflare API. It inherits functionality from AbstractMultipleResponse to handle multiple
* records of type RecordEntity. * records of type RecordEntity.
*/ */
@@ -11,7 +11,7 @@ public class RecordSingleResponse extends AbstractSingleResponse<RecordEntity> {
* *
* <p>This constructor initializes the RecordSingleResponse object by invoking the superclass * <p>This constructor initializes the RecordSingleResponse object by invoking the superclass
* constructor. The RecordSingleResponse represents a specific API response structure that * constructor. The RecordSingleResponse represents a specific API response structure that
* encapsulates a single DNS getRecord entity, providing mechanisms to interact with such data in the * encapsulates a single DNS record entity, providing mechanisms to interact with such data in the
* context of the Cloudflare API. * context of the Cloudflare API.
*/ */
public RecordSingleResponse() { public RecordSingleResponse() {
@@ -3,86 +3,86 @@ package codes.thischwa.cf.model;
import lombok.Getter; import lombok.Getter;
/** /**
* Enum representing various DNS getRecord types. * Enum representing various DNS record types.
* *
* <p>Each constant in this enum corresponds to a specific DNS getRecord type, such as "A", "AAAA", * <p>Each constant in this enum corresponds to a specific DNS record type, such as "A", "AAAA",
* "CNAME", or "TXT". This enum provides a means to standardize the representation of these getRecord * "CNAME", or "TXT". This enum provides a means to standardize the representation of these record
* types throughout the application while allowing easy retrieval of their string representation. * types throughout the application while allowing easy retrieval of their string representation.
*/ */
@Getter @Getter
public enum RecordType { public enum RecordType {
/** /**
* Represents the DNS A getRecord type. * Represents the DNS A record type.
* *
* <p>The "A" getRecord type is used to map a domain name to an IPv4 address. * <p>The "A" record type is used to map a domain name to an IPv4 address.
*/ */
A("A"), A("A"),
/** /**
* Represents the DNS AAAA getRecord type. * Represents the DNS AAAA record type.
* *
* <p>The "AAAA" getRecord type maps a domain name to an IPv6 address. * <p>The "AAAA" record type maps a domain name to an IPv6 address.
*/ */
AAAA("AAAA"), AAAA("AAAA"),
/** /**
* Represents the DNS CAA (Certificate Authority Authorization) getRecord type. * Represents the DNS CAA (Certificate Authority Authorization) record type.
* *
* <p>The "CAA" getRecord type is used to specify which certificate authorities (CAs) are allowed to * <p>The "CAA" record type is used to specify which certificate authorities (CAs) are allowed to
* issue SSL/TLS certificates for a domain. * issue SSL/TLS certificates for a domain.
*/ */
CAA("CAA"), CAA("CAA"),
/** /**
* Represents the DNS CERT getRecord type. * Represents the DNS CERT record type.
* *
* <p>The "CERT" getRecord type is used to store certificates and related certificate revocation * <p>The "CERT" record type is used to store certificates and related certificate revocation
* lists or certificate authority data in DNS zones. * lists or certificate authority data in DNS zones.
*/ */
CERT("CERT"), CERT("CERT"),
/** /**
* Represents the DNS CNAME (Canonical Name) getRecord type. * Represents the DNS CNAME (Canonical Name) record type.
* *
* <p>The "CNAME" getRecord type is used to alias one domain name to another. * <p>The "CNAME" record type is used to alias one domain name to another.
*/ */
CNAME("CNAME"), CNAME("CNAME"),
/** /**
* Represents the DNSKEY getRecord type. * Represents the DNSKEY record type.
* *
* <p>The "DNSKEY" getRecord type is used for storing public keys in DNS, as part of the DNS Security * <p>The "DNSKEY" record type is used for storing public keys in DNS, as part of the DNS Security
* Extensions (DNSSEC). It helps in verifying the authenticity of DNS responses through digital * Extensions (DNSSEC). It helps in verifying the authenticity of DNS responses through digital
* signatures. * signatures.
*/ */
DNSKEY("DNSKEY"), DNSKEY("DNSKEY"),
/** /**
* Represents the DNS DS (Delegation Signer) getRecord type. * Represents the DNS DS (Delegation Signer) record type.
* *
* <p>The "DS" getRecord type is used in the DNSSEC (Domain Name System Security Extensions) * <p>The "DS" record type is used in the DNSSEC (Domain Name System Security Extensions)
* protocol. It contains a hash of a DNSKEY getRecord which is utilized in establishing a chain of * protocol. It contains a hash of a DNSKEY record which is utilized in establishing a chain of
* trust from a parent zone to a child zone. * trust from a parent zone to a child zone.
*/ */
DS("DS"), DS("DS"),
/** /**
* Represents the DNS HTTPS (HTTP Service) getRecord type. * Represents the DNS HTTPS (HTTP Service) record type.
* *
* <p>The "HTTPS" getRecord type is used to specify information about the HTTP/3 and related services * <p>The "HTTPS" record type is used to specify information about the HTTP/3 and related services
* offered by a domain. * offered by a domain.
*/ */
HTTPS("HTTPS"), HTTPS("HTTPS"),
/** /**
* Represents the DNS LOC (Location) getRecord type. * Represents the DNS LOC (Location) record type.
* *
* <p>The "LOC" getRecord type is used to store geographical location information for a domain, * <p>The "LOC" record type is used to store geographical location information for a domain,
* including latitude, longitude, altitude, and other details. It enables associating domains with * including latitude, longitude, altitude, and other details. It enables associating domains with
* physical locations. * physical locations.
*/ */
LOC("LOC"), LOC("LOC"),
/** /**
* Represents the DNS MX (Mail Exchange) getRecord type. * Represents the DNS MX (Mail Exchange) record type.
* *
* <p>The "MX" getRecord type is used to specify the mail servers responsible for receiving email * <p>The "MX" record type is used to specify the mail servers responsible for receiving email
* messages on behalf of a domain. * messages on behalf of a domain.
*/ */
MX("MX"), MX("MX"),
/** /**
* Represents the NAPTR getRecord type for DNS configurations. * Represents the NAPTR record type for DNS configurations.
* *
* <p>This constant is used to specify NAPTR (Naming Authority Pointer) DNS records, which allow * <p>This constant is used to specify NAPTR (Naming Authority Pointer) DNS records, which allow
* for service discovery through flexible DNS-based mechanisms. NAPTR records are commonly used in * for service discovery through flexible DNS-based mechanisms. NAPTR records are commonly used in
@@ -99,7 +99,7 @@ public enum RecordType {
*/ */
NS("NS"), NS("NS"),
/** /**
* Represents the "OPENPGPKEY" DNS getRecord type. * Represents the "OPENPGPKEY" DNS record type.
* *
* <p>This constant is primarily used to identify DNS records of the type "OPENPGPKEY". It may be * <p>This constant is primarily used to identify DNS records of the type "OPENPGPKEY". It may be
* utilized within the system for operations such as creating, retrieving, updating, or managing * utilized within the system for operations such as creating, retrieving, updating, or managing
@@ -107,17 +107,17 @@ public enum RecordType {
*/ */
OPENPGPKEY("OPENPGPKEY"), OPENPGPKEY("OPENPGPKEY"),
/** /**
* Represents a DNS getRecord type. * Represents a DNS record type.
* *
* <p>The `PTR` value specifically refers to a "pointer getRecord" in the DNS system, which is * <p>The `PTR` value specifically refers to a "pointer record" in the DNS system, which is
* typically used for reverse DNS lookups. * typically used for reverse DNS lookups.
*/ */
PTR("PTR"), PTR("PTR"),
/** /**
* Represents the SMIMEA DNS getRecord type. * Represents the SMIMEA DNS record type.
* *
* <p>The SMIMEA resource getRecord is used to associate a user's certificate information for email * <p>The SMIMEA resource record is used to associate a user's certificate information for email
* message signing or encryption. This type of DNS getRecord is part of the DNS-based Authentication * message signing or encryption. This type of DNS record is part of the DNS-based Authentication
* of Named Entities (DANE) protocol. * of Named Entities (DANE) protocol.
* *
* <p>SMIMEA records provide a mechanism for utilizing certificates in email communication * <p>SMIMEA records provide a mechanism for utilizing certificates in email communication
@@ -134,41 +134,41 @@ public enum RecordType {
*/ */
SMIMEA("SMIMEA"), SMIMEA("SMIMEA"),
/** /**
* Represents a service getRecord (SRV) type in the DNS configuration model. * Represents a service record (SRV) type in the DNS configuration model.
* *
* <p>This constant may be used to identify and work with SRV getRecord types in various DNS-related * <p>This constant may be used to identify and work with SRV record types in various DNS-related
* operations or integrations. * operations or integrations.
*/ */
SRV("SRV"), SRV("SRV"),
/** /**
* Represents the DNS getRecord type "SSHFP" (SSH Fingerprint), used in DNS to store cryptographic * Represents the DNS record type "SSHFP" (SSH Fingerprint), used in DNS to store cryptographic
* fingerprints associated with SSH host keys. * fingerprints associated with SSH host keys.
* *
* <p>This DNS getRecord type provides a mechanism for verifying the authenticity of an SSH server * <p>This DNS record type provides a mechanism for verifying the authenticity of an SSH server
* before initiating a connection, enhancing the security of SSH communications. * before initiating a connection, enhancing the security of SSH communications.
*/ */
SSHFP("SSHFP"), SSHFP("SSHFP"),
/** /**
* Represents the Service Binding (SVCB) DNS getRecord type. * Represents the Service Binding (SVCB) DNS record type.
* *
* <p>The SVCB getRecord is a DNS resource getRecord used to indicate alternative endpoints or specific * <p>The SVCB record is a DNS resource record used to indicate alternative endpoints or specific
* configuration details for services. It is commonly applied in service discovery and * configuration details for services. It is commonly applied in service discovery and
* protocol-specific configurations. * protocol-specific configurations.
*/ */
SVCB("SVCB"), SVCB("SVCB"),
/** /**
* Represents a constant for the DNS-based Authentication of Named Entities (DANE) TLSA getRecord * Represents a constant for the DNS-based Authentication of Named Entities (DANE) TLSA record
* type. * type.
* *
* <p>The TLSA getRecord is used to associate a TLS server certificate or public key with the domain * <p>The TLSA record is used to associate a TLS server certificate or public key with the domain
* name (e.g., via DNSSEC). It enables cryptographically secured connections by attaching * name (e.g., via DNSSEC). It enables cryptographically secured connections by attaching
* certificate and key constraints to the specific domain. * certificate and key constraints to the specific domain.
*/ */
TLSA("TLSA"), TLSA("TLSA"),
/** /**
* Represents the TXT DNS getRecord type. * Represents the TXT DNS record type.
* *
* <p>The TXT DNS getRecord type is commonly used to store text-based information for various * <p>The TXT DNS record type is commonly used to store text-based information for various
* verification and configuration purposes, such as domain ownership verification or email * verification and configuration purposes, such as domain ownership verification or email
* authentication protocols (e.g., SPF, DKIM). * authentication protocols (e.g., SPF, DKIM).
*/ */
@@ -66,7 +66,7 @@ public class CfClientPenTest {
} }
@Test @Test
@DisplayName("Invalid getRecord content and TTL boundaries must be rejected by API") @DisplayName("Invalid record content and TTL boundaries must be rejected by API")
void testInvalidRecordCreateInputsRejected() throws Exception { void testInvalidRecordCreateInputsRejected() throws Exception {
CfDnsClient client = newClient(); CfDnsClient client = newClient();
ZoneEntity zone = client.zoneGet(ZONE_STR); ZoneEntity zone = client.zoneGet(ZONE_STR);
@@ -81,11 +81,11 @@ public class CfClientPenTest {
} }
try { try {
// A getRecord with invalid IPv4 // A record with invalid IPv4
assertThrows(CloudflareApiException.class, assertThrows(CloudflareApiException.class,
() -> client.recordCreate(zone, fqdn, 60, RecordType.A, "999.999.999.999")); () -> client.recordCreate(zone, fqdn, 60, RecordType.A, "999.999.999.999"));
// AAAA getRecord with non-IP content // AAAA record with non-IP content
assertThrows(CloudflareApiException.class, assertThrows(CloudflareApiException.class,
() -> client.recordCreate(zone, fqdn, 60, RecordType.AAAA, "not-an-ipv6")); () -> client.recordCreate(zone, fqdn, 60, RecordType.AAAA, "not-an-ipv6"));
@@ -144,7 +144,7 @@ public class CfClientTest {
// ensure clean state // ensure clean state
client.recordDeleteTypeIfExists(z, randomSld, RecordType.A, RecordType.AAAA); client.recordDeleteTypeIfExists(z, randomSld, RecordType.A, RecordType.AAAA);
// create A getRecord using recordCreate with full domain // create A record using recordCreate with full domain
createdRe1 = createdRe1 =
client.recordCreate(z, RecordEntity.build(domain, RecordType.A, TTL, "130.0.0.3")); client.recordCreate(z, RecordEntity.build(domain, RecordType.A, TTL, "130.0.0.3"));
assertNotNull(createdRe1.getId()); assertNotNull(createdRe1.getId());
@@ -163,7 +163,7 @@ public class CfClientTest {
r = aRecords.get(0); r = aRecords.get(0);
assertEquals("130.0.0.3", r.getContent()); assertEquals("130.0.0.3", r.getContent());
// create AAAA getRecord using recordCreateSld // create AAAA record using recordCreateSld
createdRe2 = createdRe2 =
client.recordCreateSld(z, randomSld, TTL, RecordType.AAAA, "2a0a:4cc0:c0:2e4::1"); client.recordCreateSld(z, randomSld, TTL, RecordType.AAAA, "2a0a:4cc0:c0:2e4::1");
List<RecordEntity> aaaaRecords = client.recordList(z, randomSld, RecordType.AAAA); List<RecordEntity> aaaaRecords = client.recordList(z, randomSld, RecordType.AAAA);
@@ -183,7 +183,7 @@ public class CfClientTest {
} else if (Objects.equals(re.getType(), RecordType.AAAA.getType())) { } else if (Objects.equals(re.getType(), RecordType.AAAA.getType())) {
assertEquals("2a0a:4cc0:c0:2e4::1", re.getContent()); assertEquals("2a0a:4cc0:c0:2e4::1", re.getContent());
} else { } else {
fail(String.format("Unexpected getRecord type: %s", re.getType())); fail(String.format("Unexpected record type: %s", re.getType()));
} }
} }
@@ -207,7 +207,7 @@ public class CfClientTest {
assertFalse(fluentList.isEmpty()); assertFalse(fluentList.isEmpty());
assertTrue(fluentList.stream().anyMatch(re -> re.getId().equals(createdRe1.getId()))); assertTrue(fluentList.stream().anyMatch(re -> re.getId().equals(createdRe1.getId())));
// update AAAA getRecord // update AAAA record
createdRe2.setContent("2a0a:4cc0:c0:2e4::2"); createdRe2.setContent("2a0a:4cc0:c0:2e4::2");
client.recordUpdate(z, createdRe2); client.recordUpdate(z, createdRe2);
aaaaRecords = client.recordList(z, randomSld, RecordType.AAAA); aaaaRecords = client.recordList(z, randomSld, RecordType.AAAA);
@@ -215,18 +215,18 @@ public class CfClientTest {
r = aaaaRecords.get(0); r = aaaaRecords.get(0);
assertEquals("2a0a:4cc0:c0:2e4::2", r.getContent()); assertEquals("2a0a:4cc0:c0:2e4::2", r.getContent());
// verify A getRecord still intact // verify A record still intact
aRecords = client.recordList(z, randomSld, RecordType.A); aRecords = client.recordList(z, randomSld, RecordType.A);
assertEquals(1, aRecords.size()); assertEquals(1, aRecords.size());
r = aRecords.get(0); r = aRecords.get(0);
assertEquals("130.0.0.3", r.getContent()); assertEquals("130.0.0.3", r.getContent());
// delete AAAA getRecord and verify it's gone // delete AAAA record and verify it's gone
assertTrue(client.recordDelete(z, createdRe2)); assertTrue(client.recordDelete(z, createdRe2));
assertThrows(CloudflareNotFoundException.class, assertThrows(CloudflareNotFoundException.class,
() -> client.recordList(z, randomSld, RecordType.AAAA)); () -> client.recordList(z, randomSld, RecordType.AAAA));
// delete A getRecord using helper and verify it's gone // delete A record using helper and verify it's gone
client.recordDeleteTypeIfExists(z, randomSld, RecordType.A); client.recordDeleteTypeIfExists(z, randomSld, RecordType.A);
assertThrows(CloudflareNotFoundException.class, assertThrows(CloudflareNotFoundException.class,
() -> client.recordList(z, randomSld, RecordType.A)); () -> client.recordList(z, randomSld, RecordType.A));
@@ -242,7 +242,7 @@ public class CfClientTest {
void testRecordEntityInvalidType() { void testRecordEntityInvalidType() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> RecordEntity.build("id123", "example.com", "INVALID_TYPE", 60, "192.168.1.1")); () -> RecordEntity.build("id123", "example.com", "INVALID_TYPE", 60, "192.168.1.1"));
assertTrue(exception.getMessage().contains("Invalid getRecord type: INVALID_TYPE")); assertTrue(exception.getMessage().contains("Invalid record type: INVALID_TYPE"));
assertTrue(exception.getMessage().contains("Must be one of:")); assertTrue(exception.getMessage().contains("Must be one of:"));
} }
@@ -441,7 +441,7 @@ public class CfClientTest {
assertNotNull(groupedRecords, "Resulting map should not be null."); assertNotNull(groupedRecords, "Resulting map should not be null.");
assertEquals(2, groupedRecords.size(), "The grouping should result in 2 FQDN keys."); assertEquals(2, groupedRecords.size(), "The grouping should result in 2 FQDN keys.");
assertEquals(2, groupedRecords.get("example.com.").size(), "The key 'example.com.' should have 2 records."); assertEquals(2, groupedRecords.get("example.com.").size(), "The key 'example.com.' should have 2 records.");
assertEquals(1, groupedRecords.get("sub.example.com.").size(), "The key 'sub.example.com.' should have 1 getRecord."); assertEquals(1, groupedRecords.get("sub.example.com.").size(), "The key 'sub.example.com.' should have 1 record.");
} }
@Test @Test