Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,20 @@ public String updateApiCollectionNameForVxlan() {
return Action.SUCCESS.toUpperCase();
}

String transportType;
public String updateTransportType() {
try {
ApiCollection apiCollection = ApiCollectionsDao.instance.getMeta(apiCollectionId);
if (apiCollection != null) {
ApiCollectionsDao.instance.updateTransportType(apiCollection, transportType);
}
} catch (Exception e) {
loggerMaker.errorAndAddToDb(e, "error in updateTransportType " + e.toString());
return Action.ERROR.toUpperCase();
}
return Action.SUCCESS.toUpperCase();
}

public String updateModuleInfo() {
try {
DbLayer.updateModuleInfo(moduleInfo);
Expand Down Expand Up @@ -4109,4 +4123,12 @@ public void setTestingRunResultId(String testingRunResultId) {
public void setUrlType(String urlType) {
this.urlType = urlType;
}

public String getTransportType() {
return transportType;
}

public void setTransportType(String transportType) {
this.transportType = transportType;
}
}
11 changes: 11 additions & 0 deletions apps/database-abstractor/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
</result>
</action>

<action name="api/updateTransportType" class="com.akto.action.DbAction" method="updateTransportType">
<interceptor-ref name="json"/>
<interceptor-ref name="defaultStack" />
<result name="SUCCESS" type="json"/>
<result name="ERROR" type="json">
<param name="statusCode">422</param>
<param name="ignoreHierarchy">false</param>
<param name="includeProperties">^actionErrors.*</param>
</result>
</action>

<action name="api/updateModuleInfoForHeartbeat" class="com.akto.action.DbAction" method="updateModuleInfo">
<interceptor-ref name="json"/>
<interceptor-ref name="defaultStack" />
Expand Down
8 changes: 8 additions & 0 deletions libs/dao/src/main/java/com/akto/dao/ApiCollectionsDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public Map<Integer, ApiCollection> getApiCollectionsMetaMap() {
return apiCollectionsMap;
}

public void updateTransportType(ApiCollection apiCollection, String transportType) {
Bson filter = Filters.eq(ApiCollection.ID, apiCollection.getId());
Bson update = Updates.set(ApiCollection.MCP_TRANSPORT_TYPE, transportType);
ApiCollectionsDao.instance.updateOne(filter, update);
apiCollection.setMcpTransportType(transportType);
}


public List<ApiCollection> getMetaAll() {
return ApiCollectionsDao.instance.findAll(new BasicDBObject(), Projections.exclude("urls"));
}
Expand Down
12 changes: 12 additions & 0 deletions libs/dao/src/main/java/com/akto/dto/ApiCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public class ApiCollection {
String sseCallbackUrl;
public static final String SSE_CALLBACK_URL = "sseCallbackUrl";

private String mcpTransportType;
public static final String MCP_TRANSPORT_TYPE = "mcpTransportType";


private static final List<String> ENV_KEYWORDS_WITH_DOT = Arrays.asList(
"staging", "preprod", "qa", "demo", "dev", "test", "svc",
"localhost", "local", "intranet", "lan", "example", "invalid",
Expand All @@ -69,6 +73,14 @@ public class ApiCollection {
"kubernetes", "internal"
);

public String getMcpTransportType() {
return mcpTransportType;
}

public void setMcpTransportType(String mcpTransportType) {
this.mcpTransportType = mcpTransportType;
}


public enum Type {
API_GROUP
Expand Down
18 changes: 18 additions & 0 deletions libs/utils/src/main/java/com/akto/data_actor/ClientActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ public void updateApiCollectionNameForVxlan(int vxlanId, String name) {
}
}

public void updateTransportType(int apiCollectionId, String transportType) {
Map<String, List<String>> headers = buildHeaders();
BasicDBObject obj = new BasicDBObject();
obj.put("apiCollectionId", apiCollectionId);
obj.put("transportType", transportType);
OriginalHttpRequest request = new OriginalHttpRequest(url + "/updateTransportType", "", "POST", obj.toString(), headers, "");
try {
OriginalHttpResponse response = ApiExecutor.sendRequest(request, true, null, false, null);
if (response.getStatusCode() != 200) {
loggerMaker.errorAndAddToDb("non 2xx response in updateTransportType", LoggerMaker.LogDb.RUNTIME);
return;
}
} catch (Exception e) {
loggerMaker.errorAndAddToDb("error updating transport type" + e + " apiCollectionId " + apiCollectionId
+ " transportType " + transportType, LoggerMaker.LogDb.RUNTIME);
}
}

public APIConfig fetchApiConfig(String configName) {
Map<String, List<String>> headers = buildHeaders();
String queryParams = "?configName="+configName;
Expand Down
2 changes: 2 additions & 0 deletions libs/utils/src/main/java/com/akto/data_actor/DataActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public abstract class DataActor {

public abstract void updateApiCollectionNameForVxlan(int vxlanId, String name);

public abstract void updateTransportType(int apiCollectionId, String transportType);

public abstract APIConfig fetchApiConfig(String configName);

public abstract void bulkWriteSingleTypeInfo(List<Object> writesForApiInfo);
Expand Down
6 changes: 6 additions & 0 deletions libs/utils/src/main/java/com/akto/data_actor/DbActor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.akto.data_actor;

import com.akto.dao.ApiCollectionsDao;
import com.akto.dto.*;
import com.akto.dto.ApiInfo.ApiInfoKey;
import com.akto.dto.billing.Organization;
Expand Down Expand Up @@ -69,6 +70,11 @@ public void updateApiCollectionNameForVxlan(int vxlanId, String name) {
DbLayer.updateApiCollectionName(vxlanId, name);
}

@Override
public void updateTransportType(int apiCollectionId, String transportType) {
ApiCollectionsDao.instance.updateTransportType(ApiCollectionsDao.instance.getMeta(apiCollectionId), transportType);
}

public APIConfig fetchApiConfig(String configName) {
return DbLayer.fetchApiconfig(configName);
}
Expand Down
Loading