Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a645486
[Automated] Update the native jar versions
SasinduDilshara Aug 11, 2025
7d8f3d0
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
5fdd437
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
67819ed
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
9b2c690
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
791175a
Add feature to update existing service in the catalog
SasinduDilshara Aug 13, 2025
a219ebb
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
d021b11
Update lang version in dependencies toml
SasinduDilshara Aug 13, 2025
2678295
Merge branch 'main' of https://github.com/ballerina-platform/module-b…
SasinduDilshara Aug 13, 2025
5e29d2b
[Automated] Update the native jar versions
SasinduDilshara Aug 13, 2025
5acfc6d
[Automated] Update the native jar versions
SasinduDilshara Aug 14, 2025
613b63a
Update update service functionality
SasinduDilshara Aug 14, 2025
78c1f9f
[Automated] Update the native jar versions
SasinduDilshara Aug 18, 2025
e54275b
[Automated] Update the native jar versions
SasinduDilshara Aug 18, 2025
666242f
Update the pagination logic
SasinduDilshara Aug 18, 2025
19bfe1e
Add service removal when user stops the services
SasinduDilshara Aug 18, 2025
8b8adf2
[Automated] Update the native jar versions
SasinduDilshara Aug 18, 2025
c3daae8
Add functionality to store service ids
SasinduDilshara Aug 18, 2025
33d6a08
[Automated] Update the native jar versions
SasinduDilshara Aug 18, 2025
c2cda40
Update delete implementation
SasinduDilshara Aug 18, 2025
f31c189
[Automated] Update the native jar versions
SasinduDilshara Aug 19, 2025
f610132
[Automated] Update the native jar versions
SasinduDilshara Aug 19, 2025
768d42d
Revert changes done to the port
SasinduDilshara Aug 19, 2025
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
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "wso2.apim.catalog"
version = "1.1.0"
version = "1.1.1"
distribution = "2201.12.0"

[platform.java21]
Expand All @@ -10,8 +10,8 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina"
artifactId = "wso2.apim.catalog-native"
version = "1.1.0"
path = "../native/build/libs/wso2.apim.catalog-native-1.1.0.jar"
version = "1.1.1"
path = "../native/build/libs/wso2.apim.catalog-native-1.1.1-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id = "wso2.apim.catalog-compiler-plugin"
class = "io.ballerina.wso2.apim.catalog.ServiceCatalogCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/wso2.apim.catalog-compiler-plugin-1.1.0.jar"
path = "../compiler-plugin/build/libs/wso2.apim.catalog-compiler-plugin-1.1.1-SNAPSHOT.jar"

[[dependency]]
path = "lib/ballerina-to-openapi-2.0.3.jar"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "wso2.apim.catalog"
version = "1.1.0"
version = "1.1.1"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "http"},
Expand Down
2 changes: 2 additions & 0 deletions ballerina/listener.bal
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public class Listener {
}

public function gracefulStop() returns error? {
check removeExistingServices(apimClient);
}

public function immediateStop() returns error? {
check removeExistingServices(apimClient);
}

public function detach(service object {} s) returns error? {
Expand Down
57 changes: 37 additions & 20 deletions ballerina/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,22 @@ configurable string[] scopes = ["service_catalog:service_view", "apim:api_view",

listener Listener 'listener = new Listener(port);

service / on 'listener {
final string[] publishedServiceIds = [];

}
Client apimClient = check new (serviceUrl = serviceUrl, config = {
auth: {
username,
tokenUrl,
password,
clientId,
clientSecret,
scopes,
clientConfig: getClientConfig(clientSecureSocketpath, clientSecureSocketpassword)
},
secureSocket: getServerCert(serverCert)
});

function publishArtifacts(ServiceArtifact[] artifacts) returns error? {
Client|error apimClient = new (serviceUrl = serviceUrl, config = {
auth: {
username,
tokenUrl,
password,
clientId,
clientSecret,
scopes,
clientConfig: getClientConfig(clientSecureSocketpath, clientSecureSocketpassword)
},
secureSocket: getServerCert(serverCert)
});

if apimClient is error {
log:printError("Error occurred while creating the client: ", apimClient);
return apimClient;
}

error? e = ();
foreach ServiceArtifact artifact in artifacts {
Service|error res = apimClient->/services.post({
Expand All @@ -76,7 +69,15 @@ function publishArtifacts(ServiceArtifact[] artifacts) returns error? {
// If there is an error, wait until other artifacts get published
if res is error {
e = res;
continue;
}

string? id = res?.id;
if id == () {
continue;
}

publishedServiceIds.push(id);
}
return e;
}
Expand All @@ -99,3 +100,19 @@ function getServerCert(string? serverCert) returns http:ClientSecureSocket? {
}
return {enable: false};
}

function removeExistingServices(Client apimClient) returns error? {
foreach string id in publishedServiceIds {
http:Response|error response = apimClient->/services/[id].delete();
if response is error {
log:printError("Error occurred while deleting the service: ", response, serviceId = id);
return response;
}

if response.statusCode != 204 {
string responseMessage = (check response.getJsonPayload()).toJsonString();
log:printError("Failed to delete service: ", serviceId = id, message = responseMessage);
return error("Failed to delete the service with id: " + id, cause = responseMessage);
}
}
}
Loading