use of org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.EndpointConfigContext in project carbon-apimgt by wso2.
the class TemplateBuilderUtil method addWebSocketResourceEndpoints.
public static void addWebSocketResourceEndpoints(API api, APITemplateBuilder builder, GatewayAPIDTO gatewayAPIDTO) throws APITemplateException, XMLStreamException {
Set<URITemplate> uriTemplates = api.getUriTemplates();
Map<String, Map<String, String>> topicMappings = api.getWebSocketTopicMappingConfiguration().getMappings();
List<GatewayContentDTO> endpointsToAdd = new ArrayList<>();
for (URITemplate resource : uriTemplates) {
String topic = resource.getUriTemplate();
Map<String, String> endpoints = topicMappings.get(topic);
// Production and Sandbox endpoints
for (Map.Entry<String, String> endpointData : endpoints.entrySet()) {
if (!"resourceKey".equals(endpointData.getKey())) {
String endpointType = endpointData.getKey();
String endpointUrl = endpointData.getValue();
String endpointConfigContext = builder.getConfigStringForWebSocketEndpointTemplate(endpointType, getWebsocketResourceKey(topic), endpointUrl);
GatewayContentDTO endpoint = new GatewayContentDTO();
// For WS APIs, resource type is not applicable,
// so we can just use the uriTemplate/uriMapping to identify the resource
endpoint.setName(getEndpointName(endpointConfigContext));
endpoint.setContent(endpointConfigContext);
endpointsToAdd.add(endpoint);
}
}
// once through resources is enough.
if (APIConstants.GRAPHQL_API.equals(api.getType())) {
break;
}
}
gatewayAPIDTO.setEndpointEntriesToBeAdd(addGatewayContentsToList(endpointsToAdd, gatewayAPIDTO.getEndpointEntriesToBeAdd()));
}
Aggregations