This commit is contained in:
2026-03-08 12:53:14 +01:00
parent 6a11868a0b
commit abb9704a87
16 changed files with 163 additions and 163 deletions
+4 -4
View File
@@ -367,7 +367,7 @@ that reduces verbosity and improves code readability.
### Basic Usage ### Basic Usage
```java ```java
// Create a DNS record // Create a DNS getRecord
client.zone("example.com") client.zone("example.com")
.record("api") .record("api")
.create(RecordType.A, "192.168.1.1",60); .create(RecordType.A, "192.168.1.1",60);
@@ -381,7 +381,7 @@ List<RecordEntity> records = client.zone("example.com")
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 record // Update a DNS getRecord
RecordEntity updated = client.zone("example.com") RecordEntity updated = client.zone("example.com")
.record("api", RecordType.A) .record("api", RecordType.A)
.update("192.168.1.2"); .update("192.168.1.2");
@@ -406,7 +406,7 @@ CfDnsClient client = new CfDnsClientBuilder()
.withApiTokenAuth("your-api-token") .withApiTokenAuth("your-api-token")
.build(); .build();
// Create a new record // Create a new getRecord
client.zone("example.com") client.zone("example.com")
.record("api") .record("api")
.create(RecordType.A, "192.168.100.1",60); .create(RecordType.A, "192.168.100.1",60);
@@ -417,7 +417,7 @@ List<RecordEntity> records = client.zone("example.com")
.get(); .get();
System.out.println("IP: "+records.get(0).getContent()); System.out.println("IP: "+records.get(0).getContent());
// Update the record // Update the getRecord
client.zone("example.com") client.zone("example.com")
.record("api",RecordType.A) .record("api",RecordType.A)
.update("192.168.100.2"); .update("192.168.100.2");
@@ -41,11 +41,11 @@ import org.jetbrains.annotations.Nullable;
* *
* // Retrieve records of a subdomain * // Retrieve records of a subdomain
* List&lt;RecordEntity&gt; records = cfDnsClient.recordList(zone, "sld"); * List&lt;RecordEntity&gt; records = cfDnsClient.recordList(zone, "sld");
* records.forEach(record -> * records.forEach(getRecord ->
* System.out.println("Record Type: " + record.getType() + ", Value: " + record.getContent()) * System.out.println("Record Type: " + getRecord.getType() + ", Value: " + getRecord.getContent())
* ); * );
* *
* // Create a record for the subdomain "api" * // Create a getRecord for the subdomain "api"
* RecordEntity created = cfDnsClient.recordCreateSld(zone, "api", 60, RecordType.A, "192.168.1.10"); * RecordEntity created = cfDnsClient.recordCreateSld(zone, "api", 60, RecordType.A, "192.168.1.10");
* System.out.println("Created Record ID: " + created.getId()); * System.out.println("Created Record ID: " + created.getId());
* </code></pre> * </code></pre>
@@ -123,7 +123,7 @@ public class CfDnsClient extends CfBasicHttpClient {
* <p>Example: * <p>Example:
* <pre><code> * <pre><code>
* 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);
* </code></pre> * </code></pre>
* *
@@ -192,11 +192,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 record types. * Optionally filters by one or more DNS getRecord 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 record types to filter the results. * @param types Optional parameter specifying one or more DNS getRecord 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
@@ -210,7 +210,7 @@ public class CfDnsClient extends CfBasicHttpClient {
/** /**
* Retrieves all record entities for a specific second-level domain (SLD) within a given DNS * Retrieves all getRecord entities for a specific second-level domain (SLD) within a given DNS
* zone using the provided paging request parameters. * zone using the provided paging request parameters.
* *
* @param zone The DNS zone entity for which the SLD records are to be fetched. * @param zone The DNS zone entity for which the SLD records are to be fetched.
@@ -231,10 +231,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 record types. * Optionally filters by one or more DNS getRecord 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 record types to filter the results. * @param types Optional parameter specifying one or more DNS getRecord 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
*/ */
@@ -248,17 +248,17 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a new DNS record for a given second-level domain (SLD) within the specified zone. * Creates a new DNS getRecord for a given second-level domain (SLD) within the specified zone.
* *
* @param zone The ZoneEntity representing the DNS zone where the record is to be created. * @param zone The ZoneEntity representing the DNS zone where the getRecord is to be created.
* @param sld The second-level domain (SLD) for which the DNS record is being created. * @param sld The second-level domain (SLD) for which the DNS getRecord is being created.
* @param ttl The time-to-live (TTL) value for the DNS record in seconds. * @param ttl The time-to-live (TTL) value for the DNS getRecord in seconds.
* @param type The RecordType specifying the type of the DNS record (e.g., A, AAAA, CNAME). * @param type The RecordType specifying the type of the DNS getRecord (e.g., A, AAAA, CNAME).
* @param content The content of the DNS record (e.g., IP address for A/AAAA records, target * @param content The content of the DNS getRecord (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 record. * @return The created RecordEntity object containing details of the newly created DNS getRecord.
* @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 record. * or creating the getRecord.
*/ */
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 {
@@ -267,14 +267,14 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a DNS record in the specified DNS zone with the provided details. * Creates a DNS getRecord in the specified DNS zone with the provided details.
* *
* @param zone the DNS zone in which the record will be created * @param zone the DNS zone in which the getRecord will be created
* @param name the name of the DNS record (e.g., www.example.com) * @param name the name of the DNS getRecord (e.g., www.example.com)
* @param ttl the time-to-live (TTL) value for the DNS record * @param ttl the time-to-live (TTL) value for the DNS getRecord
* @param type the type of the DNS record (e.g., A, AAAA, CNAME) * @param type the type of the DNS getRecord (e.g., A, AAAA, CNAME)
* @param content the content or value of the DNS record * @param content the content or value of the DNS getRecord
* @return the created DNS record as a {@link RecordEntity} object * @return the created DNS getRecord 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,
@@ -284,13 +284,13 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Creates a new DNS record in the specified zone using the Cloudflare API. * Creates a new DNS getRecord in the specified zone using the Cloudflare API.
* *
* @param zone The zone entity where the record will be created. Contains details such as zone * @param zone The zone entity where the getRecord will be created. Contains details such as zone
* ID. * ID.
* @param rec The record entity representing the DNS record to be created, including its * @param rec The getRecord entity representing the DNS getRecord to be created, including its
* attributes. * attributes.
* @return The created record entity as returned by the Cloudflare API. * @return The created getRecord 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)
@@ -305,11 +305,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes a DNS record of the specified type within a given zone on the Cloudflare API. * Deletes a DNS getRecord of the specified type within a given zone on the Cloudflare API.
* *
* @param zone The zone entity that specifies the zone in which the record exists. * @param zone The zone entity that specifies the zone in which the getRecord exists.
* @param rec The record entity that represents the DNS record to be deleted. * @param rec The getRecord entity that represents the DNS getRecord to be deleted.
* @return {@code true} if the DNS record was successfully deleted; {@code false} otherwise. * @return {@code true} if the DNS getRecord 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.
*/ */
@@ -324,11 +324,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes a DNS record of the specified type within a given zone on the Cloudflare API. * Deletes a DNS getRecord of the specified type within a given zone on the Cloudflare API.
* *
* @param zone The zone entity that specifies the zone in which the record exists. * @param zone The zone entity that specifies the zone in which the getRecord exists.
* @param id The record entity that represents the DNS record to be deleted. * @param id The getRecord entity that represents the DNS getRecord to be deleted.
* @return {@code true} if the DNS record was successfully deleted; {@code false} otherwise. * @return {@code true} if the DNS getRecord 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.
*/ */
@@ -341,12 +341,12 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Updates an existing DNS record in a specified Cloudflare zone. * Updates an existing DNS getRecord 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 record entity containing the ID of the DNS record to be updated and its updated * @param rec the getRecord entity containing the ID of the DNS getRecord to be updated and its updated
* data * data
* @return the updated record entity as returned by the Cloudflare API * @return the updated getRecord 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)
@@ -362,11 +362,11 @@ public class CfDnsClient extends CfBasicHttpClient {
} }
/** /**
* Deletes DNS records of a specific type within a given zone if they exist. If no record of the * Deletes DNS records of a specific type within a given zone if they exist. If no getRecord 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 record exists. * @param zone The DNS zone entity in which the getRecord exists.
* @param sld The second-level domain for which the record is being checked. * @param sld The second-level domain for which the getRecord 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.
*/ */
@@ -377,7 +377,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 record of type {} found for domain {}.", recordTypes, fqdn); log.trace("No getRecord of type {} found for domain {}.", recordTypes, fqdn);
return; return;
} }
for (RecordEntity rec : recs) { for (RecordEntity rec : recs) {
@@ -385,13 +385,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 record {} of type {} for zone {}: {}", fqdn, recordTypes, zone.getName(), e.getMessage()); log.error("Failed to delete getRecord {} of type {} for zone {}: {}", fqdn, recordTypes, zone.getName(), e.getMessage());
} }
} }
} }
/** /**
* Processes a batch of DNS record operations (POST, PUT, PATCH, DELETE) for a specified zone. * Processes a batch of DNS getRecord 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.
* *
@@ -407,7 +407,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' record entries // build 'clean' getRecord 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 creating a new DNS record within a specific DNS zone. The * Represents the API endpoint path for creating a new DNS getRecord 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 retrieving information about a DNS record within a * Represents the API endpoint path for retrieving information about a DNS getRecord 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 record name, which need to be provided to construct the complete path. * and the getRecord name, which need to be provided to construct the complete path.
*/ */
RECORD_INFO_NAME("/zones/%s/dns_records?name=%s"), RECORD_INFO_NAME("/zones/%s/dns_records?name=%s"),
/** /**
* Represents the API endpoint path for updating an existing DNS record within a specific DNS * Represents the API endpoint path for updating an existing DNS getRecord within a specific DNS
* zone. The endpoint path includes placeholders for the zone identifier and the record * zone. The endpoint path includes placeholders for the zone identifier and the getRecord
* 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"),
@@ -52,8 +52,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 record within a specific DNS * Represents the API endpoint path for deleting an existing DNS getRecord within a specific DNS
* zone. The endpoint path includes placeholders for the zone identifier and the record * zone. The endpoint path includes placeholders for the zone identifier and the getRecord
* 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 record-level operations. * Fluent interface for getRecord-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 record with the specified parameters. * Creates a new DNS getRecord with the specified parameters.
* *
* @param type the DNS record type (e.g., A, AAAA, CNAME) * @param type the DNS getRecord type (e.g., A, AAAA, CNAME)
* @param content the content of the DNS record (e.g., IP address) * @param content the content of the DNS getRecord (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 record * @throws CloudflareApiException if an error occurs while creating the getRecord
*/ */
RecordEntity create(RecordType type, String content, int ttl) throws CloudflareApiException; RecordEntity create(RecordType type, String content, int ttl) throws CloudflareApiException;
/** /**
* Updates an existing DNS record with new content. * Updates an existing DNS getRecord with new content.
* *
* @param newContent the new content for the DNS record * @param newContent the new content for the DNS getRecord
* @return the updated RecordEntity * @return the updated RecordEntity
* @throws CloudflareApiException if an error occurs while updating the record * @throws CloudflareApiException if an error occurs while updating the getRecord
*/ */
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 record types to delete * @param types the DNS getRecord 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 record-level operations. * Implementation of RecordOperations for fluent API access to getRecord-level operations.
*/ */
public class RecordOperationsImpl implements RecordOperations { public class RecordOperationsImpl implements RecordOperations {
@@ -17,7 +17,7 @@ public interface ZoneOperations {
* @return a RecordOperations instance for chaining record-specific operations * @return a RecordOperations instance for chaining record-specific operations
* @throws CloudflareApiException if the zone cannot be found or accessed * @throws CloudflareApiException if the zone cannot be found or accessed
*/ */
RecordOperations record(String sld) throws CloudflareApiException; RecordOperations getRecord(String sld) throws CloudflareApiException;
/** /**
* Selects a record with specific types within the zone for further operations. * Selects a record with specific types within the zone for further operations.
@@ -27,7 +27,7 @@ public interface ZoneOperations {
* @return a RecordOperations instance for chaining record-specific operations * @return a RecordOperations instance for chaining record-specific operations
* @throws CloudflareApiException if the zone cannot be found or accessed * @throws CloudflareApiException if the zone cannot be found or accessed
*/ */
RecordOperations record(String sld, @Nullable RecordType... types) throws CloudflareApiException; RecordOperations getRecord(String sld, @Nullable RecordType... types) throws CloudflareApiException;
/** /**
* Lists all DNS records within the zone, optionally filtered by types. * Lists all DNS records within the zone, optionally filtered by types.
@@ -28,12 +28,12 @@ public class ZoneOperationsImpl implements ZoneOperations {
} }
@Override @Override
public RecordOperations record(String sld) throws CloudflareApiException { public RecordOperations getRecord(String sld) throws CloudflareApiException {
return new RecordOperationsImpl(client, zone, sld, null); return new RecordOperationsImpl(client, zone, sld, null);
} }
@Override @Override
public RecordOperations record(String sld, @Nullable RecordType... types) throws CloudflareApiException { public RecordOperations getRecord(String sld, @Nullable RecordType... types) throws CloudflareApiException {
return new RecordOperationsImpl(client, zone, sld, types); return new RecordOperationsImpl(client, zone, sld, types);
} }
@@ -6,24 +6,24 @@
* *
* <p>Example usage: * <p>Example usage:
* <pre><code> * <pre><code>
* // Create a DNS record * // Create a DNS getRecord
* 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 * // Get DNS records
* List&lt;RecordEntity&gt; records = client.zone("example.com") * List&lt;RecordEntity&gt; records = client.zone("example.com")
* .record("www", RecordType.A) * .getRecord("www", RecordType.A)
* .get(); * .get();
* *
* // Update a DNS record * // Update a DNS getRecord
* client.zone("example.com") * 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);
* </code></pre> * </code></pre>
*/ */
@@ -5,11 +5,11 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/** /**
* Represents a batch entry containing different types of operations on record entities. * Represents a batch entry containing different types of operations on getRecord 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 record entities. * type of action on DNS getRecord 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 record entities. * performed on DNS getRecord 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 record entity within a specific zone. * Represents a DNS getRecord entity within a specific zone.
* *
* <p>Attributes defined in this class include: * <p>Attributes defined in this class include:
* *
* <ul> * <ul>
* <li>DNS record type such as "A" or "CNAME". * <li>DNS getRecord type such as "A" or "CNAME".
* <li>Name of the DNS record. * <li>Name of the DNS getRecord.
* <li>Content of the DNS record, such as an IP address. * <li>Content of the DNS getRecord, such as an IP address.
* <li>Flags indicating whether the record is proxiable or proxied. * <li>Flags indicating whether the getRecord is proxiable or proxied.
* <li>TTL (Time-To-Live) for the DNS record. * <li>TTL (Time-To-Live) for the DNS getRecord.
* <li>A locked status to indicate the immutability of the record. * <li>A locked status to indicate the immutability of the getRecord.
* <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 record with specific * <p>Provides a static factory method {@code build} for creating a DNS getRecord 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 record entity within a * the AbstractEntity class. The RecordEntity class represents a DNS getRecord 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 record * @param name the name of the DNS getRecord
* @param type the {@link RecordType} of the DNS record * @param type the {@link RecordType} of the DNS getRecord
* @param ttl the time-to-live (TTL) value for the DNS record * @param ttl the time-to-live (TTL) value for the DNS getRecord
* @param content the content of the DNS record, typically an IP address * @param content the content of the DNS getRecord, 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 record * @param id the unique identifier for the DNS getRecord
* @param content the content of the DNS record, typically an IP address or other record data * @param content the content of the DNS getRecord, typically an IP address or other getRecord 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 record * @param id the unique identifier for the DNS getRecord
* @param name the name of the DNS record * @param name the name of the DNS getRecord
* @param type the type of the DNS record, represented as a string (e.g., "A", "CNAME") * @param type the type of the DNS getRecord, represented as a string (e.g., "A", "CNAME")
* @param ttl the time-to-live (TTL) value for the DNS record * @param ttl the time-to-live (TTL) value for the DNS getRecord
* @param content the content of the DNS record, typically an IP address or other record data * @param content the content of the DNS getRecord, typically an IP address or other getRecord 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 record type: " + type + ". Must be one of: " throw new IllegalArgumentException("Invalid getRecord 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 record. * Retrieves the short name (subdomain) of the DNS getRecord.
* 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 record (substring before the first dot), * @return the short name of the DNS getRecord (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 record entities from the * <p>This class represents a response containing multiple DNS getRecord 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 record entity, providing mechanisms to interact with such data in the * encapsulates a single DNS getRecord 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 record types. * Enum representing various DNS getRecord types.
* *
* <p>Each constant in this enum corresponds to a specific DNS record type, such as "A", "AAAA", * <p>Each constant in this enum corresponds to a specific DNS getRecord type, such as "A", "AAAA",
* "CNAME", or "TXT". This enum provides a means to standardize the representation of these record * "CNAME", or "TXT". This enum provides a means to standardize the representation of these getRecord
* 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 record type. * Represents the DNS A getRecord type.
* *
* <p>The "A" record type is used to map a domain name to an IPv4 address. * <p>The "A" getRecord type is used to map a domain name to an IPv4 address.
*/ */
A("A"), A("A"),
/** /**
* Represents the DNS AAAA record type. * Represents the DNS AAAA getRecord type.
* *
* <p>The "AAAA" record type maps a domain name to an IPv6 address. * <p>The "AAAA" getRecord type maps a domain name to an IPv6 address.
*/ */
AAAA("AAAA"), AAAA("AAAA"),
/** /**
* Represents the DNS CAA (Certificate Authority Authorization) record type. * Represents the DNS CAA (Certificate Authority Authorization) getRecord type.
* *
* <p>The "CAA" record type is used to specify which certificate authorities (CAs) are allowed to * <p>The "CAA" getRecord 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 record type. * Represents the DNS CERT getRecord type.
* *
* <p>The "CERT" record type is used to store certificates and related certificate revocation * <p>The "CERT" getRecord 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) record type. * Represents the DNS CNAME (Canonical Name) getRecord type.
* *
* <p>The "CNAME" record type is used to alias one domain name to another. * <p>The "CNAME" getRecord type is used to alias one domain name to another.
*/ */
CNAME("CNAME"), CNAME("CNAME"),
/** /**
* Represents the DNSKEY record type. * Represents the DNSKEY getRecord type.
* *
* <p>The "DNSKEY" record type is used for storing public keys in DNS, as part of the DNS Security * <p>The "DNSKEY" getRecord 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) record type. * Represents the DNS DS (Delegation Signer) getRecord type.
* *
* <p>The "DS" record type is used in the DNSSEC (Domain Name System Security Extensions) * <p>The "DS" getRecord type is used in the DNSSEC (Domain Name System Security Extensions)
* protocol. It contains a hash of a DNSKEY record which is utilized in establishing a chain of * protocol. It contains a hash of a DNSKEY getRecord 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) record type. * Represents the DNS HTTPS (HTTP Service) getRecord type.
* *
* <p>The "HTTPS" record type is used to specify information about the HTTP/3 and related services * <p>The "HTTPS" getRecord 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) record type. * Represents the DNS LOC (Location) getRecord type.
* *
* <p>The "LOC" record type is used to store geographical location information for a domain, * <p>The "LOC" getRecord 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) record type. * Represents the DNS MX (Mail Exchange) getRecord type.
* *
* <p>The "MX" record type is used to specify the mail servers responsible for receiving email * <p>The "MX" getRecord 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 record type for DNS configurations. * Represents the NAPTR getRecord 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 record type. * Represents the "OPENPGPKEY" DNS getRecord 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 record type. * Represents a DNS getRecord type.
* *
* <p>The `PTR` value specifically refers to a "pointer record" in the DNS system, which is * <p>The `PTR` value specifically refers to a "pointer getRecord" 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 record type. * Represents the SMIMEA DNS getRecord type.
* *
* <p>The SMIMEA resource record is used to associate a user's certificate information for email * <p>The SMIMEA resource getRecord is used to associate a user's certificate information for email
* message signing or encryption. This type of DNS record is part of the DNS-based Authentication * message signing or encryption. This type of DNS getRecord 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 record (SRV) type in the DNS configuration model. * Represents a service getRecord (SRV) type in the DNS configuration model.
* *
* <p>This constant may be used to identify and work with SRV record types in various DNS-related * <p>This constant may be used to identify and work with SRV getRecord types in various DNS-related
* operations or integrations. * operations or integrations.
*/ */
SRV("SRV"), SRV("SRV"),
/** /**
* Represents the DNS record type "SSHFP" (SSH Fingerprint), used in DNS to store cryptographic * Represents the DNS getRecord 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 record type provides a mechanism for verifying the authenticity of an SSH server * <p>This DNS getRecord 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 record type. * Represents the Service Binding (SVCB) DNS getRecord type.
* *
* <p>The SVCB record is a DNS resource record used to indicate alternative endpoints or specific * <p>The SVCB getRecord is a DNS resource getRecord 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 record * Represents a constant for the DNS-based Authentication of Named Entities (DANE) TLSA getRecord
* type. * type.
* *
* <p>The TLSA record is used to associate a TLS server certificate or public key with the domain * <p>The TLSA getRecord 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 record type. * Represents the TXT DNS getRecord type.
* *
* <p>The TXT DNS record type is commonly used to store text-based information for various * <p>The TXT DNS getRecord 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 record content and TTL boundaries must be rejected by API") @DisplayName("Invalid getRecord 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 record with invalid IPv4 // A getRecord 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 record with non-IP content // AAAA getRecord 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"));
@@ -127,7 +127,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 record using recordCreate with full domain // create A getRecord 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());
@@ -146,7 +146,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 record using recordCreateSld // create AAAA getRecord 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);
@@ -166,7 +166,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 record type: %s", re.getType())); fail(String.format("Unexpected getRecord type: %s", re.getType()));
} }
} }
@@ -191,7 +191,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 record // update AAAA getRecord
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);
@@ -199,18 +199,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 record still intact // verify A getRecord 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 record and verify it's gone // delete AAAA getRecord 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 record using helper and verify it's gone // delete A getRecord 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));
@@ -226,7 +226,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 record type: INVALID_TYPE")); assertTrue(exception.getMessage().contains("Invalid getRecord type: INVALID_TYPE"));
assertTrue(exception.getMessage().contains("Must be one of:")); assertTrue(exception.getMessage().contains("Must be one of:"));
} }
@@ -373,7 +373,7 @@ public class CfClientTest {
try { try {
// Test fluent create // Test fluent create
RecordEntity created = client.zone(ZONE_STR) RecordEntity created = client.zone(ZONE_STR)
.record(fluentSld) .getRecord(fluentSld)
.create(RecordType.A, "192.168.100.1", TTL); .create(RecordType.A, "192.168.100.1", TTL);
assertNotNull(created.getId()); assertNotNull(created.getId());
@@ -382,7 +382,7 @@ public class CfClientTest {
// Test fluent get // Test fluent get
List<RecordEntity> records = client.zone(ZONE_STR) List<RecordEntity> records = client.zone(ZONE_STR)
.record(fluentSld, RecordType.A) .getRecord(fluentSld, RecordType.A)
.get(); .get();
assertEquals(1, records.size()); assertEquals(1, records.size());
@@ -390,18 +390,18 @@ public class CfClientTest {
// Test fluent update // Test fluent update
RecordEntity updated = client.zone(ZONE_STR) RecordEntity updated = client.zone(ZONE_STR)
.record(fluentSld, RecordType.A) .getRecord(fluentSld, RecordType.A)
.update("192.168.100.2"); .update("192.168.100.2");
assertEquals("192.168.100.2", updated.getContent()); assertEquals("192.168.100.2", updated.getContent());
// Test fluent delete // Test fluent delete
client.zone(ZONE_STR) client.zone(ZONE_STR)
.record(fluentSld) .getRecord(fluentSld)
.delete(RecordType.A); .delete(RecordType.A);
assertThrows(CloudflareNotFoundException.class, assertThrows(CloudflareNotFoundException.class,
() -> client.zone(ZONE_STR).record(fluentSld, RecordType.A).get()); () -> client.zone(ZONE_STR).getRecord(fluentSld, RecordType.A).get());
} finally { } finally {
try { try {
@@ -425,7 +425,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 record."); assertEquals(1, groupedRecords.get("sub.example.com.").size(), "The key 'sub.example.com.' should have 1 getRecord.");
} }
@Test @Test