Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
8 changes: 4 additions & 4 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "data.jsondata"
version = "1.1.0"
version = "1.1.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
Expand All @@ -73,7 +73,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.14.0"
version = "2.14.3"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -240,7 +240,7 @@ modules = [
[[package]]
org = "ballerina"
name = "oauth2"
version = "2.14.0"
version = "2.14.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down 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
56 changes: 56 additions & 0 deletions ballerina/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ function publishArtifacts(ServiceArtifact[] artifacts) returns error? {
return apimClient;
}

Service[]|error services = retrieveAllExisitingservices(apimClient, artifacts);
if services is error {
log:printError("Error occurred while retrieving existing services: ", services);
return services;
}

error? removeResult = removeExistingServices(apimClient, services);
if removeResult is error {
log:printError("Error occurred while removing existing services: ", removeResult);
return removeResult;
}

error? e = ();
foreach ServiceArtifact artifact in artifacts {
Service|error res = apimClient->/services.post({
Expand Down Expand Up @@ -99,3 +111,47 @@ function getServerCert(string? serverCert) returns http:ClientSecureSocket? {
}
return {enable: false};
}

function retrieveAllExisitingservices(Client apimClient, ServiceArtifact[] artifacts) returns Service[]|error {
Service[] services = [];
string serviceKeys = getCommaSeparatedServiceKeys(artifacts);
int offset = 0;
int 'limit = 25;
while true {
ServiceList|error serviceList = apimClient->/services(key = serviceKeys, offset = offset, 'limit = 'limit);
if serviceList is error {
log:printError("Error occurred while retrieving existing services: ", serviceList);
return serviceList;
}

Service[]? fetchedServices = serviceList.list;
Pagination? pagination = serviceList.pagination;
if fetchedServices != () {
services.push(...fetchedServices);
}

if pagination?.next == () {
break;
}

offset += 'limit;
}

return services;
}

function removeExistingServices(Client apimClient, Service[] services) returns error? {
foreach Service serviceObject in services {
string? id = serviceObject.id;
if id == () {
log:printWarn("Service ID is not available for service: " + serviceObject.serviceKey.toBalString());
continue;
}

http:Response|error response = apimClient->/services/[id].delete();
if response is error {
log:printError("Error occurred while deleting existing service: ", response);
return response;
}
}
}
3 changes: 3 additions & 0 deletions ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ isolated function createBodyParts(record {|anydata...;|} anyRecord, map<Encoding
}
return entities;
}

function getCommaSeparatedServiceKeys(ServiceArtifact[] artifacts) returns string =>
string:'join(",", ...from ServiceArtifact artifact in artifacts select artifact.serviceKey);
Loading