-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: Support Custom Sequence as a Backend of an API #12524
Conversation
|
@@ -487,6 +487,218 @@ paths: | |||
-H "Content-Type: application/json" -d @data.json | |||
"https://127.0.0.1:9443/api/am/publisher/v4/apis/7a2298c4-c905-403f-8fac-38c73301631f/topics"' | |||
|
|||
/apis/{apiId}/custom-backend/{customBackendId}/content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to sequence-backend/{sandbox/Prod}/{sequenceID} check dev portal key type implementation
schema: | ||
type: string | ||
content: | ||
application/zip: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the content type
@@ -487,6 +487,218 @@ paths: | |||
-H "Content-Type: application/json" -d @data.json | |||
"https://127.0.0.1:9443/api/am/publisher/v4/apis/7a2298c4-c905-403f-8fac-38c73301631f/topics"' | |||
|
|||
/apis/{apiId}/custom-backend/{customBackendId}/content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets remove the sequenceID
schema: | ||
type: string | ||
content: | ||
application/json: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a text type
endpointConfig.put("sequence_id", resultSet.getString("ID")); | ||
} | ||
} catch (SQLException ex) { | ||
handleException("Error when retrieving Custom Backend of API: " + apiUUID, ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the relevant exception codes
resultSet = ps.executeQuery(); | ||
while (resultSet.next()) { | ||
map.put("type", resultSet.getString("TYPE")); | ||
map.put("sequence_name", resultSet.getString("NAME")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define and use Static variables
1fac89a
to
3a6e34f
Compare
3d896b0
to
4823c10
Compare
@@ -65,6 +66,10 @@ public interface APIProvider extends APIManager { | |||
Comment getComment(ApiTypeWrapper apiTypeWrapper, String commentId, Integer replyLimit, Integer replyOffset) throws | |||
APIManagementException; | |||
|
|||
void deleteCustomBackendByID(String apiUUID, String type) throws APIManagementException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add Java doc comments. Check other places as well
@@ -0,0 +1,58 @@ | |||
package org.wso2.carbon.apimgt.api.model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add license header
.BACKEND_REQUEST_START_TIME)); | ||
messageContext.setProperty(APIMgtGatewayConstants.BACKEND_LATENCY, System.currentTimeMillis() - | ||
executionStartTime); | ||
if (APIUtil.isAnalyticsEnabled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this be applied in Sequence as a backend scenario
@@ -21,6 +21,7 @@ | |||
import com.fasterxml.jackson.core.JsonProcessingException; | |||
import com.fasterxml.jackson.databind.ObjectMapper; | |||
import com.google.gson.Gson; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this new line
addPstmt.setString(6, rs.getString("NAME")); | ||
addPstmt.addBatch(); | ||
count++; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these are commented out
* @return The Sequence of the Custom Backend as an Input Stream | ||
* @throws APIManagementException If an error occurs while reading, throws an error | ||
*/ | ||
public static InputStream getCustomBackendSequence(String extractedFolderPath, String customBackendFileName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we returning an InputStream? where are we closing this?
} | ||
} | ||
} catch (IOException | ParseException ex) { | ||
throw new APIManagementException("Error when updating Endpoint Configuration", ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add more details to this error, API name etc.
36c3c1c
to
00d6c1c
Compare
addCustomBackend(apiUUID, sequenceName, null, sequence, type, connection, backendUUID); | ||
connection.commit(); | ||
} catch (SQLException e) { | ||
handleException("Error while adding Custom Backend for API : " + apiUUID, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to add a rollback in case of an exception. Check other places as well.
String fileName = extractedFolderPath + File.separator + sequenceName; | ||
if (checkFileExistence(fileName)) { | ||
if (log.isDebugEnabled()) { | ||
log.debug("Found policy definition file " + fileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be not policy but custom backend right?
@@ -1858,6 +1858,17 @@ CREATE TABLE IF NOT EXISTS AM_API ( | |||
UNIQUE (API_UUID) | |||
); | |||
|
|||
CREATE TABLE IF NOT EXISTS AM_API_SEQUENCE_BACKEND ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add the database changes to multi-dc scripts as well.
@@ -0,0 +1,142 @@ | |||
package org.wso2.carbon.apimgt.rest.api.publisher.v1.dto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add the license header. Check other places as well
import io.swagger.annotations.*; | ||
import java.util.Objects; | ||
|
||
import javax.xml.bind.annotation.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove the * and add all the dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an auto generated one
0e4a9ac
to
068529c
Compare
1889651
to
d12fca0
Compare
Purpose
Some API developers want to use connectors within the api manager to implement mediation logic as they do not want to use an additional MI deployment if their use cases are simple. Within the API Manager, currently, we do not have a construct that will allow us to facilitate this requirement.
Approach
Affected Flows
Please refer - wso2/api-manager#3007 (comment)
Issue