<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.segu23</groupId>
<artifactId>cloudflare-sdk-kv</artifactId>
<version>1.1.2</version>
</dependency>
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.segu23:cloudflare-sdk-kv:1.0'
}
IWorkerKVService workerKVService = CloudflareKVConfig.builder()
.setAccountIdentifier("XXXXXXXXXX")
.setAuthorizationToken("XXXXXXXXXX")
.setApiKey("XXXXXXXXXX")
.setApiEmail("XXXXXXXXXX")
.build();
ListNamespacesResponse listNamespacesResponse = workerKVService.listNamespaces();
CreateNamespaceResponse createNamespaceResponse = workerKVService.createNamespace("namespace-title");
Namespace namespace = workerKVService.findNamespaceByName("namespace-title");
RemoveNamespaceResponse removeNamespaceResponse = workerKVService.removeNamespace(namespace.getId());
RenameNamespaceResponse renameNamespaceResponse = workerKVService.renameNamespace(namespace.getId(), "new-namespace-title");
DeleteMultipleKeyValuePairsResponse deleteMultipleKeyValuePairsResponse = workerKVService.deleteMultipleKeyValuePairs(namespace.getId(), new String[]{"firstKey", "secondKey"});
WriteMultipleKeyValuePairsResponse writeMultipleKeyValuePairsResponse = workerKVService.writeMultipleKeyValuePairs(namespace.getId(),
new KeyValuePair[]{
new KeyValuePair()
.setKey("firstKey")
.setValue("example firstKey value")
.setMetadata(Map.of(
"firstMetadata", "firstMetadata value",
"secondMetadata", "secondMetadata value"
)),
new KeyValuePair()
.setKey("secondKey")
.setValue("example secondKey value")
}
);
ListNamespaceKeysResponse listNamespaceKeysResponse = workerKVService.listNamespaceKeys(namespace.getId());
ReadMetadataKeyResponse readMetadataKeyResponse = workerKVService.readMetadataKey(namespace.getId(), "firstKey");
DeleteKeyValuePairResponse deleteKeyValuePairResponse = workerKVService.deleteKeyValuePair(namespace.getId(), "firstKey");
String firstKeyValue = workerKVService.readKeyValuePair(namespace.getId(), "firstKey");
WriteKeyValuePairWithMetadataResponse writeKeyValuePairWithMetadataResponse = workerKVService.writeKeyValuePairWithMetadata(namespace.getId(),
"firstKey", "firstKeyValue",
Map.of(
"firstMetadata", "firstMetadata value",
"secondMetadata", "secondMetadata value"
)
);