Standardize and simplify README code examples by eliminating unnecessary line continuations, improving readability, and enhancing method chaining for DNS operations.

This commit is contained in:
2026-01-06 14:35:25 +01:00
parent 5098e17172
commit 25fd480e69
+25 -12
View File
@@ -136,7 +136,12 @@ List<RecordEntity> records = cfDnsClient.recordList(zone, "sld");
records. records.
forEach(record -> forEach(record ->
System.out.println("Record Type: " + record.getType() + ", Value: " + record.getContent()) System.out.
println("Record Type: "+record.getType()
+", Value: "+record.
getContent())
); );
``` ```
@@ -469,9 +474,11 @@ RecordEntity updated = client.zone("example.com")
// Delete DNS records // Delete DNS records
client. client.
zone("example.com"). zone("example.com")
.
record("old-service"). record("old-service")
.
delete(RecordType.A, RecordType.AAAA); delete(RecordType.A, RecordType.AAAA);
``` ```
@@ -491,9 +498,11 @@ CfDnsClient client = new CfDnsClient("email@example.com", "yourApiKey");
// Create a new record // Create a new record
client. client.
zone("example.com"). zone("example.com")
.
record("api"). record("api")
.
create(RecordType.A, "192.168.100.1",60); create(RecordType.A, "192.168.100.1",60);
@@ -510,25 +519,29 @@ getContent());
// Update the record // Update the record
client. client.
zone("example.com"). zone("example.com")
.
record("api",RecordType.A). record("api",RecordType.A)
.
update("192.168.100.2"); update("192.168.100.2");
// Clean up // Clean up
client. client.
zone("example.com"). zone("example.com")
.
record("api"). record("api")
.
delete(RecordType.A); delete(RecordType.A);
``` ```
--- ---
### Notes on Error Handling # Notes on Error Handling
The `CfDnsClient` provides internal error-handling mechanisms through exceptions. For example: The `CfDnsClient` provides internal error-handling mechanisms through exceptions. For example:
- `CloudflareApiException` is thrown for errors during API communication or invalid responses. - `CloudflareApiException` is thrown for errors during API communication or invalid responses.
@@ -542,7 +555,7 @@ To enable exception throwing for empty results:
CfDnsClient client = new CfDnsClient(true, "email@example.com", "yourApiKey"); CfDnsClient client = new CfDnsClient(true, "email@example.com", "yourApiKey");
``` ```
#### Example: ## Example:
```java ```java
try { try {
@@ -564,7 +577,7 @@ getContent());
--- ---
### Summary # Summary
`CfDnsClient` offers a simple interface for managing DNS entries via Cloudflare's public API, allowing seamless CRUD `CfDnsClient` offers a simple interface for managing DNS entries via Cloudflare's public API, allowing seamless CRUD
operations and automation-friendly workflows. operations and automation-friendly workflows.