diff --git a/pom.xml b/pom.xml
index fbbc1e8..aff9fa7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.6.1-SNAPSHOT
+ 2.7.0-SNAPSHOT
maven-plugin
apigee-config-maven-plugin
Plugin to manage configuration in Apigee
diff --git a/samples/APIandConfig/shared-pom.xml b/samples/APIandConfig/shared-pom.xml
index 5cbaeeb..29db31a 100644
--- a/samples/APIandConfig/shared-pom.xml
+++ b/samples/APIandConfig/shared-pom.xml
@@ -69,7 +69,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.6.0
+ 2.7.0
create-config-targetserver
diff --git a/samples/EdgeConfig/resources/edge/env/dev/aliases.json b/samples/EdgeConfig/resources/edge/env/dev/aliases.json
new file mode 100644
index 0000000..d746171
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/aliases.json
@@ -0,0 +1,28 @@
+[
+ {
+ "alias":"testSelfSignedCert",
+ "keystorename": "testKeyStorename",
+ "format": "selfsignedcert",
+ "keySize":"2048",
+ "sigAlg":"SHA256withRSA",
+ "subject":{
+ "commonName":"testcommonName"
+ },
+ "certValidityInDays":"90"
+ },
+ {
+ "alias":"testAliasKeyCertFileAndKey",
+ "keystorename": "testKeyStorename",
+ "format": "keycertfile",
+ "certFilePath":"/tmp/certs/keystore.pem",
+ "keyFilePath":"/tmp/certs/keystore.key",
+ "password":"dummy"
+ },
+ {
+ "alias":"testAliasPKCS12",
+ "keystorename": "testKeyStorename",
+ "format": "pkcs12",
+ "filePath":"/tmp/certs/myKeystore.p12",
+ "password":"dummy"
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/flowhooks.json b/samples/EdgeConfig/resources/edge/env/dev/flowhooks.json
new file mode 100644
index 0000000..414d1a7
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/flowhooks.json
@@ -0,0 +1,6 @@
+[
+ {
+ "flowHookPoint":"PreTargetFlowHook",
+ "sharedFlow":"test"
+ }
+ ]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/keystores.json b/samples/EdgeConfig/resources/edge/env/dev/keystores.json
new file mode 100644
index 0000000..98d9fce
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/keystores.json
@@ -0,0 +1,5 @@
+[
+ {
+ "name" : "testKeyStorename"
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/kvms.json b/samples/EdgeConfig/resources/edge/env/dev/kvms.json
new file mode 100644
index 0000000..0b37717
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/kvms.json
@@ -0,0 +1,15 @@
+[
+ {
+ "entry": [
+ {
+ "name": "COMPANY",
+ "value": "example.com"
+ },
+ {
+ "name": "PREFIX",
+ "value": "EXMPL"
+ }
+ ],
+ "name": "backend_account_config"
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/references.json b/samples/EdgeConfig/resources/edge/env/dev/references.json
new file mode 100644
index 0000000..b79c9e1
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/references.json
@@ -0,0 +1,7 @@
+[
+ {
+ "name" : "sampleReference",
+ "refers": "testKeyStorename",
+ "resourceType": "KeyStore"
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/resourcefiles.json b/samples/EdgeConfig/resources/edge/env/dev/resourcefiles.json
new file mode 100644
index 0000000..2ea132e
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/resourcefiles.json
@@ -0,0 +1,12 @@
+[
+ {
+ "name": "test",
+ "type": "jsc",
+ "file": "./resourceFiles/jsc/test.js"
+ },
+ {
+ "name": "foobar",
+ "type": "properties",
+ "file": "./resourceFiles/properties/foobar.properties"
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/resources/edge/env/dev/targetServers.json b/samples/EdgeConfig/resources/edge/env/dev/targetServers.json
new file mode 100644
index 0000000..80be0a7
--- /dev/null
+++ b/samples/EdgeConfig/resources/edge/env/dev/targetServers.json
@@ -0,0 +1,22 @@
+[
+ {
+ "name": "Enterprisetarget",
+ "host": "example.com",
+ "isEnabled": true,
+ "port": 8080
+ },
+ {
+ "name": "ESBTarget",
+ "host": "enterprise.com",
+ "isEnabled": true,
+ "port": 8080,
+ "sSLInfo": {
+ "clientAuthEnabled": "false",
+ "enabled": "true",
+ "ignoreValidationErrors": "false",
+ "keyAlias": "key_alias",
+ "keyStore": "keystore_name",
+ "trustStore": "truststore_name"
+ }
+ }
+]
\ No newline at end of file
diff --git a/samples/EdgeConfig/shared-pom.xml b/samples/EdgeConfig/shared-pom.xml
index 8a326ee..70c60a2 100644
--- a/samples/EdgeConfig/shared-pom.xml
+++ b/samples/EdgeConfig/shared-pom.xml
@@ -26,7 +26,7 @@
com.apigee.edge.config
apigee-config-maven-plugin
- 2.6.0
+ 2.7.0
create-config-targetserver
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/KVMMojo.java b/src/main/java/com/apigee/edge/config/mavenplugin/KVMMojo.java
index 50015d4..d2e7ef5 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/KVMMojo.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/KVMMojo.java
@@ -71,6 +71,14 @@ enum OPTIONS {
public static class KVM {
@Key
public String name;
+ @Key
+ public List entry;
+ }
+ public static class KVMEntry {
+ @Key
+ public String name;
+ @Key
+ public String value;
}
public KVMMojo() {
@@ -114,6 +122,26 @@ protected String getKVMName(String payload) throws MojoFailureException {
throw new MojoFailureException(e.getMessage());
}
}
+
+ //Apigee API does not allow "/" in the key name, so need to check before create/update operation
+ protected void checkForInvalidKey(List kvms) throws MojoFailureException {
+ if (buildOption == OPTIONS.delete) //This check is not needed for delete option
+ return;
+ Gson gson = new Gson();
+ try {
+ for (String kvmString : kvms) {
+ KVM kvm = gson.fromJson(kvmString, KVM.class);
+ if(kvm!=null && kvm.entry!=null && kvm.entry.size()>0) {
+ for (KVMEntry kvmEntry : kvm.entry) {
+ if(kvmEntry!=null && kvmEntry.name!=null && kvmEntry.name.contains("/"))
+ throw new MojoFailureException("KVM key: "+ kvmEntry.name +" is invalid. Keys cannot contain \"/\" character ");
+ }
+ }
+ }
+ } catch (JsonParseException e) {
+ throw new MojoFailureException(e.getMessage());
+ }
+ }
protected void doOrgUpdate(List kvms, String scope)
throws MojoFailureException {
@@ -135,6 +163,11 @@ protected void doOrgUpdate(List kvms, String scope)
if (existingKVM.contains(kvmName)) {
switch (buildOption) {
+ case update:
+ logger.info("Org KVM \"" + kvmName +
+ "\" exists. Updating.");
+ kvmOrg.update(new KvmValueObject(serverProfile, kvmName, kvm));
+ break;
case create:
logger.info("Org KVM \"" + kvmName +
"\" already exists. Skipping.");
@@ -144,14 +177,6 @@ protected void doOrgUpdate(List kvms, String scope)
"\" already exists. Deleting.");
deleteOrgKVM(serverProfile, kvmName);
break;
- case update:
- logger.info("Org KVM \"" + kvmName +
- "\" exists. Updating.");
- //deleting the KVM and re-creating the KVM and entries
- deleteOrgKVM(serverProfile, kvmName);
- createOrgKVM(serverProfile, kvmName);
- kvmOrg.update(new KvmValueObject(serverProfile, kvmName, kvm));
- break;
case sync:
logger.info("Org KVM \"" + kvmName +
"\" already exists. Deleting and recreating.");
@@ -206,6 +231,11 @@ protected void doEnvUpdate(List kvms, String scope)
if (existingKVM.contains(kvmName)) {
switch (buildOption) {
+ case update:
+ logger.info("Env KVM \"" + kvmName +
+ "\" exists. Updating.");
+ kvmEnv.update(new KvmValueObject(serverProfile, kvmName, kvm));
+ break;
case create:
logger.info("Env KVM \"" + kvmName +
"\" already exists. Skipping.");
@@ -215,14 +245,6 @@ protected void doEnvUpdate(List kvms, String scope)
"\" already exists. Deleting.");
deleteEnvKVM(serverProfile, kvmName);
break;
- case update:
- logger.info("Env KVM \"" + kvmName +
- "\" exists. Updating.");
- //deleting the KVM and re-creating the KVM and entries
- deleteEnvKVM(serverProfile, kvmName);
- createEnvKVM(serverProfile, kvmName);
- kvmEnv.update(new KvmValueObject(serverProfile, kvmName, kvm));
- break;
case sync:
logger.info("Env KVM \"" + kvmName +
"\" already exists. Deleting and recreating.");
@@ -277,6 +299,11 @@ protected void doAPIUpdate(String api, List kvms)
if (existingKVM.contains(kvmName)) {
switch (buildOption) {
+ case update:
+ logger.info("API KVM \"" + kvmName +
+ "\" exists. Updating.");
+ kvmApi.update(new KvmValueObject(serverProfile, api, kvmName, kvm));
+ break;
case create:
logger.info("API KVM \"" + kvmName +
"\" already exists. Skipping.");
@@ -285,15 +312,6 @@ protected void doAPIUpdate(String api, List kvms)
logger.info("API KVM \"" + kvmName +
"\" already exists. Deleting.");
deleteAPIKVM(serverProfile, api, kvmName);
- break;
- case update:
- logger.info("API KVM \"" + kvmName +
- "\" exists. Updating.");
- //deleting the KVM and re-creating the KVM and entries
- deleteAPIKVM(serverProfile, api, kvmName);
- createAPIKVM(serverProfile, api, kvmName);
- kvmApi.update(new KvmValueObject(serverProfile, api, kvmName, kvm));
-
break;
case sync:
logger.info("API KVM \"" + kvmName +
@@ -361,6 +379,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (kvms == null || kvms.size() == 0) {
logger.info("No org scoped KVM config found.");
} else {
+ checkForInvalidKey(kvms);
doOrgUpdate(kvms, scope);
}
@@ -369,6 +388,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (kvms == null || kvms.size() == 0) {
logger.info("No env scoped KVM config found.");
} else {
+ checkForInvalidKey(kvms);
doEnvUpdate(kvms, scope);
}
@@ -385,6 +405,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
logger.info(
"No API scoped KVM config found for " + api);
} else {
+ checkForInvalidKey(kvms);
doAPIUpdate(api, kvms);
}
}
@@ -633,3 +654,4 @@ public static List getAPIKVM(ServerProfile profile, String api)
+
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmApi.java b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmApi.java
index e63f10b..ad18b64 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmApi.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmApi.java
@@ -11,7 +11,7 @@ public class KvmApi extends KvmOperations implements Kvm {
@Override
public HttpResponse getKvm(KvmValueObject kvmValueObject) throws IOException {
RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
- return restUtil.getAPIConfig(kvmValueObject.getProfile(),
+ return restUtil.getAPIConfig(kvmValueObject.getProfile(),
kvmValueObject.getApi(),
"keyvaluemaps/"+kvmValueObject.getKvmName());
}
@@ -39,20 +39,40 @@ public HttpResponse updateKvmEntries(KvmValueObject kvmValueObject, String kvmEn
kvmEntryValue);
}
+ @Override
+ public HttpResponse updateKvmEntriesForNonCpsOrg(KvmValueObject kvmValueObject) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.updateAPIConfig(kvmValueObject.getProfile(),
+ kvmValueObject.getApi(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName(),
+ kvmValueObject.getKvm());
+ }
+
@Override
public HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
- return restUtil.createAPIConfig(kvmValueObject.getProfile(),
+ return restUtil.createAPIConfig(kvmValueObject.getProfile(),
kvmValueObject.getApi(),
"keyvaluemaps",
kvmValueObject.getKvmName(),
"entries",
kvmEntryValue);
}
+
+ @Override
+ public HttpResponse deleteKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.deleteAPIConfig(kvmValueObject.getProfile(),
+ kvmValueObject.getApi(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName()+ "/entries/"+kvmEntryValue);
+ }
@Override
public void update(KvmValueObject kvmValueObject)
throws IOException, MojoFailureException {
super.update(kvmValueObject);
}
+
}
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmEnv.java b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmEnv.java
index d3c79e6..c7f3600 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmEnv.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmEnv.java
@@ -36,6 +36,15 @@ public HttpResponse updateKvmEntries(KvmValueObject kvmValueObject, String kvmEn
kvmEntryValue);
}
+ @Override
+ public HttpResponse updateKvmEntriesForNonCpsOrg(KvmValueObject kvmValueObject) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.updateEnvConfig(kvmValueObject.getProfile(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName(),
+ kvmValueObject.getKvm());
+ }
+
@Override
public HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
@@ -45,6 +54,15 @@ public HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEn
"entries",
kvmEntryValue);
}
+
+ @Override
+ public HttpResponse deleteKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.deleteEnvConfig(kvmValueObject.getProfile(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName()+"/entries/"+kvmEntryValue);
+ }
+
@Override
public void update(KvmValueObject kvmValueObject)
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOperations.java b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOperations.java
index 3421cd1..b59c01a 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOperations.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOperations.java
@@ -1,6 +1,7 @@
package com.apigee.edge.config.mavenplugin.kvm;
import java.io.IOException;
+import java.net.URLEncoder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -23,12 +24,30 @@ public abstract class KvmOperations {
public abstract HttpResponse updateKvmEntries(KvmValueObject kvmValueObject, String kvmEntryName, String kvmEntryValue) throws IOException;
+ public abstract HttpResponse updateKvmEntriesForNonCpsOrg(KvmValueObject kvmValueObject) throws IOException;
+
public abstract HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException;
+ public abstract HttpResponse deleteKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException;
+
public void update(KvmValueObject kvmValueObject)
throws IOException, MojoFailureException {
- JSONArray entries = getEntriesConfig(kvmValueObject.getKvm());
+ updateKvm(kvmValueObject);
+// if(isOrgCpsEnabled(kvmValueObject)){
+// updateKvmForCpsOrg(kvmValueObject);
+// }else {
+// updateKvmForNonCpsOrg(kvmValueObject);
+// }
+
+ }
+
+// private Boolean isOrgCpsEnabled(KvmValueObject kvmValueObject) throws MojoFailureException {
+// return kvmValueObject.getProfile().getCpsEnabled();
+// }
+
+ private void updateKvm(KvmValueObject kvmValueObject) throws MojoFailureException, IOException {
+ JSONArray entries = getEntriesConfig(kvmValueObject.getKvm());
HttpResponse response;
for (Object entry: entries){
@@ -40,7 +59,10 @@ public void update(KvmValueObject kvmValueObject)
logger.info("No change to KVM - "+ kvmValueObject.getKvmName()+"-"+entryName +". Skipping !");
continue;
}else if(doesEntryAlreadyExistForOrg(kvmValueObject, entryName)){
- response = updateKvmEntries(kvmValueObject, entryName, entryJson.toJSONString());
+ response = updateKvmEntries(kvmValueObject, entryName, entryJson.toJSONString());
+// logger.info("KVM Entry: "+ entryName + " already exist, so deleting and creating");
+// deleteKvmEntries(kvmValueObject, URLEncoder.encode(entryName, "UTF-8")); //encoding as entryName could contain special characters
+// response = createKvmEntries(kvmValueObject, entryJson.toJSONString());
}else{
response = createKvmEntries(kvmValueObject, entryJson.toJSONString());
}
@@ -60,6 +82,32 @@ public void update(KvmValueObject kvmValueObject)
}
}
+ /*private void updateKvmForNonCpsOrg(KvmValueObject kvmValueObject)
+ throws IOException {
+ if(!kvmValueObject.getProfile().getKvmOverride()) {
+ logger.info("Override is set to false");
+ HttpResponse response = getKvm(kvmValueObject);
+ String responseString = response.parseAsString();
+ logger.debug("Get KVM Response " + response.getContentType() + "\n" + responseString);
+ if(compareJSON(responseString, kvmValueObject.getKvm())) {
+ logger.info("No change to KVM - "+ kvmValueObject.getKvmName()+". Skipping !");
+ return;
+ }
+ }
+ HttpResponse response = updateKvmEntriesForNonCpsOrg(kvmValueObject);
+ try {
+
+ logger.debug("Response " + response.getContentType() + "\n" +
+ response.parseAsString());
+ if (response.isSuccessStatusCode())
+ logger.info("Update Success.");
+
+ } catch (HttpResponseException e) {
+ logger.error("KVM update error " + e.getMessage());
+ throw new IOException(e.getMessage());
+ }
+ }*/
+
private static JSONArray getEntriesConfig(String kvm) throws MojoFailureException {
JSONParser parser = new JSONParser();
JSONObject entry;
@@ -75,18 +123,24 @@ private static JSONArray getEntriesConfig(String kvm) throws MojoFailureExceptio
private boolean doesEntryAlreadyExistForOrg(KvmValueObject kvmValueObject, String kvmEntryName) {
try {
- HttpResponse response = getEntriesForKvm(kvmValueObject, kvmEntryName);
+ //double URL encoding so the entry name with special characters like #?/ are decoded by GAAMBO correctly - https://github.com/apigee/apigee-config-maven-plugin/issues/192#issuecomment-1852050814
+ HttpResponse response = getEntriesForKvm(kvmValueObject, URLEncoder.encode(URLEncoder.encode(kvmEntryName, "UTF-8"), "UTF-8"));
+
if (response == null) {
return false;
}
+
logger.debug("Response " + response.getContentType() + "\n" +
response.parseAsString());
+
if (response.isSuccessStatusCode()) {
return true;
}
+
} catch (IOException e) {
logger.error("Get KVM Entry error " + e.getMessage());
}
+
return false;
}
@@ -99,12 +153,15 @@ private boolean doesEntryAlreadyExistForOrg(KvmValueObject kvmValueObject, Strin
*/
private boolean compareKVMEntries(KvmValueObject kvmValueObject, String kvmEntryName, String kvmEntryValue) {
try {
-
- HttpResponse response = getEntriesForKvm(kvmValueObject, kvmEntryName);
+ //double URL encoding so the entry name with special characters like #?/ are decoded by GAAMBO correctly - https://github.com/apigee/apigee-config-maven-plugin/issues/192#issuecomment-1852050814
+ HttpResponse response = getEntriesForKvm(kvmValueObject, URLEncoder.encode(URLEncoder.encode(kvmEntryName, "UTF-8"), "UTF-8"));
if (response == null) {
+ logger.info("this is false");
return false;
}
String responseValue = parseValuefromKVM(response.parseAsString());
+ logger.info("responseValue: "+ responseValue);
+ logger.info("kvmEntryValue: "+ kvmEntryValue);
if (responseValue.equals(kvmEntryValue)) {
return true;
}
diff --git a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOrg.java b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOrg.java
index 780107a..8f82907 100644
--- a/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOrg.java
+++ b/src/main/java/com/apigee/edge/config/mavenplugin/kvm/KvmOrg.java
@@ -11,7 +11,7 @@ public class KvmOrg extends KvmOperations implements Kvm {
@Override
public HttpResponse getKvm(KvmValueObject kvmValueObject) throws IOException {
RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
- return restUtil.getOrgConfig(kvmValueObject.getProfile(),
+ return restUtil.getOrgConfig(kvmValueObject.getProfile(),
"keyvaluemaps/"+kvmValueObject.getKvmName());
}
@@ -36,6 +36,15 @@ public HttpResponse updateKvmEntries(KvmValueObject kvmValueObject, String kvmEn
kvmEntryValue);
}
+ @Override
+ public HttpResponse updateKvmEntriesForNonCpsOrg(KvmValueObject kvmValueObject) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.updateOrgConfig(kvmValueObject.getProfile(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName(),
+ kvmValueObject.getKvm());
+ }
+
@Override
public HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
@@ -45,7 +54,15 @@ public HttpResponse createKvmEntries(KvmValueObject kvmValueObject, String kvmEn
"entries",
kvmEntryValue);
}
-
+
+ @Override
+ public HttpResponse deleteKvmEntries(KvmValueObject kvmValueObject, String kvmEntryValue) throws IOException {
+ RestUtil restUtil = new RestUtil(kvmValueObject.getProfile());
+ return restUtil.deleteOrgConfig(kvmValueObject.getProfile(),
+ "keyvaluemaps",
+ kvmValueObject.getKvmName()+"/entries/"+kvmEntryValue);
+ }
+
@Override
public void update(KvmValueObject kvmValueObject)
throws IOException, MojoFailureException {
diff --git a/src/main/java/com/apigee/edge/config/rest/RestUtil.java b/src/main/java/com/apigee/edge/config/rest/RestUtil.java
index b1fa3f2..af3405d 100644
--- a/src/main/java/com/apigee/edge/config/rest/RestUtil.java
+++ b/src/main/java/com/apigee/edge/config/rest/RestUtil.java
@@ -329,7 +329,7 @@ public HttpResponse updateEnvConfig(ServerProfile profile,
String payload)
throws IOException {
- String importCmd = profile.getHostUrl() + "/"
+ String cmd = profile.getHostUrl() + "/"
+ profile.getApi_version() + "/organizations/"
+ profile.getOrg() + "/environments/"
+ profile.getEnvironment() + "/" + resource + "/"
@@ -337,7 +337,7 @@ public HttpResponse updateEnvConfig(ServerProfile profile,
+ "/" + subResource +"/"
+ subResourceId;
- return executeAPIPost(profile, payload, importCmd);
+ return executeAPIPut(profile, payload, cmd);
}
public HttpResponse updateEnvConfigUpload(ServerProfile profile, String resource, String resourceId,
@@ -625,14 +625,14 @@ public HttpResponse updateOrgConfig(ServerProfile profile,
String payload)
throws IOException {
- String importCmd = profile.getHostUrl() + "/"
+ String cmd = profile.getHostUrl() + "/"
+ profile.getApi_version() + "/organizations/"
+ profile.getOrg() + "/" + resource + "/"
+ URLEncoder.encode(resourceId, "UTF-8")
+ "/" + subResource + "/"
+ subResourceId;
- return executeAPIPost(profile, payload, importCmd);
+ return executeAPIPut(profile, payload, cmd);
}
public HttpResponse updateOrgConfigUpload(ServerProfile profile,
@@ -908,7 +908,7 @@ public HttpResponse updateAPIConfig(ServerProfile profile,
String payload)
throws IOException {
- String importCmd = profile.getHostUrl() + "/"
+ String cmd = profile.getHostUrl() + "/"
+ profile.getApi_version() + "/organizations/"
+ profile.getOrg() + "/apis/"
+ api + "/" + resource + "/"
@@ -916,7 +916,7 @@ public HttpResponse updateAPIConfig(ServerProfile profile,
+ "/" + subResource + "/"
+ subResourceId;
- return executeAPIPost(profile, payload, importCmd);
+ return executeAPIPut(profile, payload, cmd);
}
public HttpResponse updateAPIConfigUpload(ServerProfile profile, String api, String resource, String resourceId,
@@ -1118,6 +1118,28 @@ private HttpResponse executeAPIPost(ServerProfile profile, String payload,
return response;
}
+
+ private HttpResponse executeAPIPut(ServerProfile profile, String payload,
+ String cmd)
+ throws IOException {
+
+ ByteArrayContent content = new ByteArrayContent("application/json",
+ payload.getBytes());
+
+ HttpRequest restRequest = REQUEST_FACTORY
+ .buildPutRequest(new GenericUrl(cmd), content);
+ restRequest.setReadTimeout(0);
+
+ HttpResponse response;
+ try {
+ response = executeAPI(profile, restRequest);
+ } catch (HttpResponseException e) {
+ logger.error("Apigee call failed " + e.getMessage());
+ throw new IOException(e.getMessage());
+ }
+
+ return response;
+ }
/**
*