https://github.com/dorkbox/kloudflareapi
Cloudflare API v4 for Kotlin
https://github.com/dorkbox/kloudflareapi
Last synced: 11 months ago
JSON representation
Cloudflare API v4 for Kotlin
- Host: GitHub
- URL: https://github.com/dorkbox/kloudflareapi
- Owner: dorkbox
- License: other
- Created: 2019-06-24T14:44:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-12T21:24:35.000Z (about 2 years ago)
- Last Synced: 2024-10-04T21:56:55.186Z (almost 2 years ago)
- Language: Kotlin
- Size: 426 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
KloudflareAPI
=======
###### [](https://git.dorkbox.com/dorkbox/KloudflareAPI) [](https://github.com/dorkbox/KloudflareAPI) [](https://gitlab.com/dorkbox/KloudflareAPI)
KloudflareAPI is an kotlin project that implements (some of) the Cloudflare v4 API, allowing one manage DNS zones and user information
Pull requests are welcome!
- This is for cross-platform use, specifically - linux 32/64, mac 64, and windows 32/64. Java 8+
``` java
val email = "test@example.com"
val token = "ac1d3f45b51cc5d23e47aa4ac7c07b54d60f2"
val kloudflare = Kloudflare(email, token)
println(kloudflare.getUser())
val listZones = kloudflare.listZones()
listZones.forEach { zone ->
println("${zone.name} : ${zone.id}")
val dnsRecords = kloudflare.listDnsRecords(zone)
dnsRecords.forEach { dnsRecord ->
if (dnsRecord.type == RecordType.A || dnsRecord.type == RecordType.AAAA) {
val domainLength = zone.name.length
val length = dnsRecord.name.length - domainLength
val domainName = if (length == 0) {
"@"
}
else {
// -1 because we don't want the '.'
dnsRecord.name.subSequence(0, length - 1)
}
println(" $domainName ${dnsRecord.type} : ${dnsRecord.id}")
val newDnsRecord = CreateDnsRecord(zone)
newDnsRecord.type = RecordType.A
newDnsRecord.name = "test"
newDnsRecord.content = "1.2.3.4"
val newRecord = kloudflare.createDnsRecord(newDnsRecord)
println("Created: ${newRecord.name} -> ${newRecord.content}")
}
}
}
```
Maven Info
---------
```
...
com.dorkbox
KloudflareAPI
2.3
```
Gradle Info
---------
````
dependencies {
...
compile 'com.dorkbox:KloudflareAPI:1.3'
}
````
License
---------
This project is © 2019 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.