Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ax-openapi-connectors into worldbank-date-optional
  • Loading branch information
aneeshafedo committed Jun 22, 2021
2 parents eb28456 + 81c0d89 commit d6910bd
Show file tree
Hide file tree
Showing 25 changed files with 8,060 additions and 30 deletions.
31 changes: 31 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if (project.hasProperty("remote")){
remote = new Boolean(project.property("remote").toString())
}

Utils.loadOpenAPIProperties(project.projectDir.absolutePath)
String openApiPackageDirPath = project.projectDir.absolutePath + "/openapi";
updatedBallerinaPackages = Utils.findUpdatedBallerinaPackages(openApiPackageDirPath)

// TODO: Remove this cleanup task once the file override enabled
// task cleanup {
// println "Cleaning up generated code..."
Expand Down Expand Up @@ -101,6 +105,33 @@ if (project.hasProperty("remote")){
// }
// }

// Temporarily added.
task codeBuild {
// Pulling slalpha5 distribution if not available
if (project.hasProperty("remote") ) {
if (remote) {
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal dist pull slalpha5"
}

exec {
commandLine 'sh', '-c', "rm -rf ${ballerinaDistributionPath}/bin/../dependencies/jdk-11.0.8+10-jre"
}
}
}

// Changing the build distribution to SL Alpha5
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal dist use slalpha5"
}
for (String path : updatedBallerinaPackages) {
println "Code building..."
exec {
commandLine 'sh', '-c', "${ballerinaDistributionPath}/bin/bal build -c ${path}"
}
}
}

task releaseConnector {
//TODO: check and remove the snapshot part in the ballerina toml
if (project.hasProperty("release") ) {
Expand Down
2 changes: 1 addition & 1 deletion openapi/covid19/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "covid19"
version = "0.3.0"
version = "0.4.0"
license= ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["covid19", "covid19 vaccine"]
Expand Down
22 changes: 11 additions & 11 deletions openapi/covid19/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public client class Client {
remote isolated function getGlobalStatus(@display {label: "Yesterday"} string? yesterday = (), @display {label: "Two Days Ago"} string? twoDaysAgo = (), @display {label: "Allow Null"} string? allowNull = ()) returns CovidAll|error {
string path = string `/v3/covid-19/all`;
map<anydata> queryParam = {yesterday: yesterday, twoDaysAgo: twoDaysAgo, allowNull: allowNull};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidAll response = check self.clientEp-> get(path, targetType = CovidAll);
return response;
}
Expand All @@ -52,7 +52,7 @@ public client class Client {
remote isolated function getUSAStatusByState(@display {label: "State Name"} string states, @display {label: "Yesterday"} string? yesterday = (), @display {label: "Allow Null"} string? allowNull = ()) returns CovidState|error {
string path = string `/v3/covid-19/states/${states}`;
map<anydata> queryParam = {yesterday: yesterday, allowNull: allowNull};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidState response = check self.clientEp-> get(path, targetType = CovidState);
return response;
}
Expand All @@ -68,7 +68,7 @@ public client class Client {
remote isolated function getStatusByContinent(@display {label: "Continent"} string continent, @display {label: "Yesterday"} string? yesterday = (), @display {label: "Two Days Ago"} string? twoDaysAgo = (), @display {label: "Strict"} string? strict = (), @display {label: "Allow Null"} string? allowNull = ()) returns CovidContinent|error {
string path = string `/v3/covid-19/continents/${continent}`;
map<anydata> queryParam = {yesterday: yesterday, twoDaysAgo: twoDaysAgo, strict: strict, allowNull: allowNull};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidContinent response = check self.clientEp-> get(path, targetType = CovidContinent);
return response;
}
Expand All @@ -84,7 +84,7 @@ public client class Client {
remote isolated function getStatusByCountry(@display {label: "Country"} string country, @display {label: "Yesterday"} string? yesterday = (), @display {label: "Two Days Ago"} string? twoDaysAgo = (), @display {label: "Strict"} string? strict = (), @display {label: "Allow Null"} string? allowNull = ()) returns CovidCountry|error {
string path = string `/v3/covid-19/countries/${country}`;
map<anydata> queryParam = {yesterday: yesterday, twoDaysAgo: twoDaysAgo, strict: strict, allowNull: allowNull};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidCountry response = check self.clientEp-> get(path, targetType = CovidCountry);
return response;
}
Expand All @@ -96,7 +96,7 @@ public client class Client {
remote isolated function getGlobalStatusInTimeSeries(@display {label: "Number Of Days"} string? lastdays = ()) returns CovidHistoricalAll|error {
string path = string `/v3/covid-19/historical/all`;
map<anydata> queryParam = {lastdays: lastdays};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidHistoricalAll response = check self.clientEp-> get(path, targetType = CovidHistoricalAll);
return response;
}
Expand All @@ -109,7 +109,7 @@ public client class Client {
remote isolated function getTimeSeriesbycountry(@display {label: "Country"} string country, @display {label: "Number Of Days"} string? lastdays = ()) returns CovidHistoricalCountry|error {
string path = string `/v3/covid-19/historical/${country}`;
map<anydata> queryParam = {lastdays: lastdays};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidHistoricalCountry response = check self.clientEp-> get(path, targetType = CovidHistoricalCountry);
return response;
}
Expand All @@ -123,7 +123,7 @@ public client class Client {
remote isolated function getTimeSeriesByProvince(@display {label: "Country"} string country, @display {label: "Province"} string province, @display {label: "Number of Days"} string? lastdays = ()) returns CovidHistoricalProvince|error {
string path = string `/v3/covid-19/historical/${country}/${province}`;
map<anydata> queryParam = {lastdays: lastdays};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CovidHistoricalProvince response = check self.clientEp-> get(path, targetType = CovidHistoricalProvince);
return response;
}
Expand All @@ -144,7 +144,7 @@ public client class Client {
remote isolated function getTotalGlobalVaccineDosesAdministered(@display {label: "Number of Days"} string? lastdays = ()) returns SimpleVaccineTimeline|error {
string path = string `/v3/covid-19/vaccine/coverage`;
map<anydata> queryParam = {lastdays: lastdays};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
SimpleVaccineTimeline response = check self.clientEp-> get(path, targetType = SimpleVaccineTimeline);
return response;
}
Expand All @@ -157,7 +157,7 @@ public client class Client {
remote isolated function getVaccineCoverageByCountry(@display {label: "Country"} string country, @display {label: "Last Days"} string? lastdays = ()) returns VaccineCountryCoverage|error {
string path = string `/v3/covid-19/vaccine/coverage/countries/${country}`;
map<anydata> queryParam = {lastdays: lastdays};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
VaccineCountryCoverage response = check self.clientEp-> get(path, targetType = VaccineCountryCoverage);
return response;
}
Expand All @@ -167,7 +167,7 @@ public client class Client {
#
# + queryParam - Query parameter map
# + return - Returns generated Path or error at failure of client initialization
isolated function getPathForQueryParam(map<anydata> queryParam) returns string {
isolated function getPathForQueryParam(map<anydata> queryParam) returns string|error {
string[] param = [];
param[param.length()] = "?";
foreach var [key, value] in queryParam.entries() {
Expand All @@ -181,7 +181,7 @@ isolated function getPathForQueryParam(map<anydata> queryParam) returns str
}
param[param.length()] = "=";
if value is string {
string updateV = checkpanic url:encode(value, "UTF-8");
string updateV = check url:encode(value, "UTF-8");
param[param.length()] = updateV;
} else {
param[param.length()] = value.toString();
Expand Down
2 changes: 1 addition & 1 deletion openapi/openweathermap/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "openweathermap"
version = "0.3.0"
version = "0.4.0"
authors = ["Ballerina"]
license= ["Apache-2.0"]
keywords = ["open weather map", "weather data", "weather forecast"]
Expand Down
8 changes: 4 additions & 4 deletions openapi/openweathermap/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public client class Client {
remote isolated function getCurretWeatherData(@display {label: "CityName or StateCode or CountryCode"} string? q = (), @display {label: "City Id"} string? id = (), @display {label: "Latitude"} string? lat = (), @display {label: "Longitude"} string? lon = (), @display {label: "Zip Code"} string? zip = (), @display {label: "Units"} string? units = (), @display {label: "Language"} string? lang = (), @display {label: "Mode"} string? mode = ()) returns CurrentWeatherData|error {
string path = string `/weather`;
map<anydata> queryParam = {q: q, id: id, lat: lat, lon: lon, zip: zip, units: units, lang: lang, mode: mode, appid: self.apiKeys["appid"]};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
CurrentWeatherData response = check self.clientEp-> get(path, targetType = CurrentWeatherData);
return response;
}
Expand All @@ -65,7 +65,7 @@ public client class Client {
remote isolated function getWeatherForecast(@display {label: "Latitude"} string lat, @display {label: "Longtitude"} string lon, @display {label: "Exclude"} string? exclude = (), @display {label: "Units"} string? units = (), @display {label: "Language"} string? lang = ()) returns WeatherForecast|error {
string path = string `/onecall`;
map<anydata> queryParam = {lat: lat, lon: lon, exclude: exclude, units: units, lang: lang, appid: self.apiKeys["appid"]};
path = path + getPathForQueryParam(queryParam);
path = path + check getPathForQueryParam(queryParam);
WeatherForecast response = check self.clientEp-> get(path, targetType = WeatherForecast);
return response;
}
Expand All @@ -75,7 +75,7 @@ public client class Client {
#
# + queryParam - Query parameter map
# + return - Returns generated Path or error at failure of client initialization
isolated function getPathForQueryParam(map<anydata> queryParam) returns string {
isolated function getPathForQueryParam(map<anydata> queryParam) returns string|error {
string[] param = [];
param[param.length()] = "?";
foreach var [key, value] in queryParam.entries() {
Expand All @@ -89,7 +89,7 @@ isolated function getPathForQueryParam(map<anydata> queryParam) returns str
}
param[param.length()] = "=";
if value is string {
string updateV = checkpanic url:encode(value, "UTF-8");
string updateV = check url:encode(value, "UTF-8");
param[param.length()] = updateV;
} else {
param[param.length()] = value.toString();
Expand Down
1 change: 1 addition & 0 deletions openapi/sendgrid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
11 changes: 11 additions & 0 deletions openapi/sendgrid/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
org = "ballerinax"
name = "sendgrid"
version = "0.1.0"
authors = ["Ballerina"]
license= ["Apache-2.0"]
keywords = ["sendgrid", "send mail", "sendgrid alerts"]
repository = "https://github.com/ballerina-platform/ballerinax-openapi-connectors"

[build-options]
observabilityIncluded = true
22 changes: 22 additions & 0 deletions openapi/sendgrid/Package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Connects to Sendgrid API from Ballerina.

## Module Overview

The Sendgrid connector consume the data exposed in https://api.sendgrid.com/v3. It is currently supporting the following operations.

- Send Mail
- Retrieve all Alerts
- Create a new Alert
- Update Alert by Id
- Delete Alert by Id
- List all Subusers
- Create Subuser
- Delete Subuser by Name
- Retrieve all Blocks
- Get Suppression Spam Reports

## Compatibility

| Ballerina Language Versions | Sendgrid API |
|:----------------------------:|:------------------------:|
| Swan Lake Alpha 5 | v3 |
Loading

0 comments on commit d6910bd

Please sign in to comment.