diff --git a/.github/workflows/publish-pre-release.yml b/.github/workflows/publish-pre-release.yml
new file mode 100644
index 00000000..c7eb5e41
--- /dev/null
+++ b/.github/workflows/publish-pre-release.yml
@@ -0,0 +1,58 @@
+name: Publish pre-release
+
+on:
+ workflow_dispatch:
+
+jobs:
+ publish-release:
+ runs-on: ubuntu-latest
+ if: github.repository_owner == 'ballerina-platform'
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'adopt'
+ java-version: 11
+ - name: Build with Gradle
+ env:
+ packageUser: ${{ github.actor }}
+ packagePAT: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ git config --global user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
+ git config --global user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
+ ./gradlew build -x check -x test
+ - name: Set version env variable
+ run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties)" >> $GITHUB_ENV
+ - name: Pre release dependency version update
+ env:
+ GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
+ run: |
+ echo "Version: ${VERSION}"
+ git checkout -b release-${VERSION}
+ sed -i 's/ballerinaLangVersion=\(.*\)-SNAPSHOT/ballerinaLangVersion=\1/g' gradle.properties
+ sed -i 's/ballerinaLangVersion=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/ballerinaLangVersion=\1/g' gradle.properties
+ sed -i 's/stdlib\(.*\)=\(.*\)-SNAPSHOT/stdlib\1=\2/g' gradle.properties
+ sed -i 's/stdlib\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/stdlib\1=\2/g' gradle.properties
+ sed -i 's/observe\(.*\)=\(.*\)-SNAPSHOT/observe\1=\2/g' gradle.properties
+ sed -i 's/observe\(.*\)=\(.*\)-[0-9]\{8\}-[0-9]\{6\}-.*$/observe\1=\2/g' gradle.properties
+ git add gradle.properties
+ git commit -m "Move dependencies to stable version" || echo "No changes to commit"
+ - name: Publish artifact
+ env:
+ GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
+ BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
+ packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
+ packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
+ publishUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
+ publishPAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
+ run: |
+ ./gradlew clean release -Prelease.useAutomaticVersion=true
+ ./gradlew -Pversion=${VERSION} publish -x test -PpublishToCentral=true
+ - name: GitHub Release and Release Sync PR
+ env:
+ GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
+ run: |
+ gh release create v$VERSION --title "module-ballerinax-azure.functions-v$VERSION"
+ gh pr create --title "[Automated] Sync master after $VERSION release" --body "Sync master after $VERSION release"
diff --git a/.gitignore b/.gitignore
index e9a4896f..572028bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,5 @@ target
.ballerina
.idea
*.iml
+
+compiler-plugin-tests/src/test/resources/handlers/.vscode/
diff --git a/README.md b/README.md
index a6b9f32e..f0bc504d 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ import ballerinax/azure_functions as af;
// HTTP request/response with no authentication
@af:Function
public isolated function hello(@af:HTTPTrigger { authLevel: "anonymous" } string payload)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
return "Hello, " + payload + "!";
}
@@ -39,7 +39,7 @@ public isolated function hello(@af:HTTPTrigger { authLevel: "anonymous" } string
public isolated function fromHttpToQueue(af:Context ctx,
@af:HTTPTrigger af:HTTPRequest req,
@af:QueueOutput { queueName: "queue1" } af:StringOutputBinding msg)
- returns @af:HTTPOutput af:HTTPBinding {
+ returns @af:HttpOutput af:HTTPBinding {
msg.value = req.body;
return { statusCode: 200, payload: "Request: " + req.toString() };
}
@@ -68,7 +68,7 @@ public isolated function fromBlobToQueue(af:Context ctx,
@af:Function
public isolated function httpTriggerBlobInput(@af:HTTPTrigger af:HTTPRequest req,
@af:BlobInput { path: "bpath1/{Query.name}" } byte[]? blobIn)
- returns @af:HTTPOutput string {
+ returns @af:HttpOutput string {
int length = 0;
if blobIn is byte[] {
length = blobIn.length();
@@ -81,7 +81,7 @@ public isolated function httpTriggerBlobInput(@af:HTTPTrigger af:HTTPRequest req
@af:Function
public isolated function httpTriggerBlobOutput(@af:HTTPTrigger af:HTTPRequest req,
@af:BlobOutput { path: "bpath1/{Query.name}" } af:StringOutputBinding bb)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
bb.value = req.body;
return "Blob: " + req.query["name"].toString() + " Content: " +
bb?.value.toString();
@@ -91,7 +91,7 @@ public isolated function httpTriggerBlobOutput(@af:HTTPTrigger af:HTTPRequest re
@af:Function
public isolated function httpTriggerBlobOutput2(@af:HTTPTrigger af:HTTPRequest req,
@af:BlobOutput { path: "bpath1/{Query.name}" } af:BytesOutputBinding bb)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
bb.value = [65, 66, 67, 97, 98];
return "Blob: " + req.query["name"].toString() + " Content: " +
bb?.value.toString();
@@ -102,7 +102,7 @@ public isolated function httpTriggerBlobOutput2(@af:HTTPTrigger af:HTTPRequest r
public isolated function sendSMS(@af:HTTPTrigger af:HTTPRequest req,
@af:TwilioSmsOutput { fromNumber: "+12069845840" }
af:TwilioSmsOutputBinding tb)
- returns @af:HTTPOutput string {
+ returns @af:HttpOutput string {
tb.to = req.query["to"].toString();
tb.body = req.body.toString();
return "Message - to: " + tb?.to.toString() + " body: " + tb?.body.toString();
@@ -138,7 +138,7 @@ public isolated function httpTriggerCosmosDBInput1(
@af:CosmosDBInput { connectionStringSetting: "CosmosDBConnection",
databaseName: "db1", collectionName: "c1",
id: "{Query.id}", partitionKey: "{Query.country}" } json dbReq)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
return dbReq.toString();
}
@@ -148,7 +148,7 @@ public isolated function httpTriggerCosmosDBInput2(
@af:CosmosDBInput { connectionStringSetting: "CosmosDBConnection",
databaseName: "db1", collectionName: "c1",
id: "{Query.id}", partitionKey: "{Query.country}" } Person? dbReq)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
return dbReq.toString();
}
@@ -159,14 +159,14 @@ public isolated function httpTriggerCosmosDBInput3(
databaseName: "db1", collectionName: "c1",
sqlQuery: "select * from c1 where c1.country = {country}" }
Person[] dbReq)
- returns @af:HTTPOutput string|error {
+ returns @af:HttpOutput string|error {
return dbReq.toString();
}
// HTTP request to write records to CosmosDB
@af:Function
public isolated function httpTriggerCosmosDBOutput1(
- @af:HTTPTrigger af:HTTPRequest httpReq, @af:HTTPOutput af:HTTPBinding hb)
+ @af:HTTPTrigger af:HTTPRequest httpReq, @af:HttpOutput af:HTTPBinding hb)
returns @af:CosmosDBOutput { connectionStringSetting: "CosmosDBConnection",
databaseName: "db1", collectionName: "c1" } json {
json entry = { id: uuid:createType1AsString(), name: "Saman", country: "Sri Lanka" };
@@ -177,7 +177,7 @@ public isolated function httpTriggerCosmosDBOutput1(
@af:Function
public isolated function httpTriggerCosmosDBOutput2(
@af:HTTPTrigger af:HTTPRequest httpReq,
- @af:HTTPOutput af:HTTPBinding hb)
+ @af:HttpOutput af:HTTPBinding hb)
returns @af:CosmosDBOutput {
connectionStringSetting: "CosmosDBConnection",
databaseName: "db1", collectionName: "c1" } json {
diff --git a/ballerina-tests/Ballerina.toml b/ballerina-tests/Ballerina.toml
index 781cbce5..1645dbc2 100644
--- a/ballerina-tests/Ballerina.toml
+++ b/ballerina-tests/Ballerina.toml
@@ -1,4 +1,9 @@
[package]
org = "ballerinax"
name = "azure_functions_tests"
-version = "2.1.1"
+version = "3.0.0-alpha.1"
+
+[[dependency]]
+org = "ballerinax"
+name = "azure_functions"
+version = "3.0.0-alpha.1"
diff --git a/ballerina-tests/build.gradle b/ballerina-tests/build.gradle
index d8045708..a1e3030b 100644
--- a/ballerina-tests/build.gradle
+++ b/ballerina-tests/build.gradle
@@ -22,14 +22,14 @@ import org.apache.tools.ant.taskdefs.condition.Os
description = 'Ballerinax - Azure Functions Tests'
def packageName = "azure_functions"
-def packageOrg = "ballerinax" //TODO change
+def packageOrg = "ballerinax"
def moduleName = "tests"
def tomlVersion = stripBallerinaExtensionVersion("${project.version}")
def ballerinaTomlFilePlaceHolder = new File("${project.rootDir}/build-config/resources/BallerinaTest.toml")
def ballerinaTomlFile = new File("$project.projectDir/Ballerina.toml")
def ballerinaDist = "${project.rootDir}/target/ballerina-runtime"
def distributionBinPath = "${ballerinaDist}/bin"
-def testCoverageParam = "--code-coverage --includes=*"
+def testCoverageParam = "--test-report --code-coverage --coverage-format=xml --includes=io.ballerina.stdlib.azure.functions.*:ballerinax.azure_functions"
def stripBallerinaExtensionVersion(String extVersion) {
if (extVersion.matches(project.ext.timestampedVersionRegex)) {
diff --git a/ballerina-tests/main.bal b/ballerina-tests/main.bal
deleted file mode 100644
index a372656d..00000000
--- a/ballerina-tests/main.bal
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-//
-// WSO2 Inc. licenses this file to you under the Apache License,
-// Version 2.0 (the "License"); you may not use this file except
-// in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-import ballerina/uuid;
-import ballerinax/azure_functions as af;
-
-// HTTP request/response with no authentication
-@af:Function
-public isolated function hello(@af:HTTPTrigger { authLevel: "anonymous" } string payload)
- returns @af:HTTPOutput string|error {
- return "Hello, " + payload + "!";
-}
-
-// HTTP request to add data to a queue
-@af:Function
-public isolated function fromHttpToQueue(af:Context ctx,
- @af:HTTPTrigger {} af:HTTPRequest req,
- @af:QueueOutput { queueName: "queue1" } af:StringOutputBinding msg)
- returns @af:HTTPOutput af:HTTPBinding {
- msg.value = req.body;
- return { statusCode: 200, payload: "Request: " + req.toString() };
-}
-
-// A message put to a queue is copied to another queue
-@af:Function
-public isolated function fromQueueToQueue(af:Context ctx,
- @af:QueueTrigger { queueName: "queue2" } string inMsg,
- @af:QueueOutput { queueName: "queue3" } af:StringOutputBinding outMsg) {
- ctx.log("In Message: " + inMsg);
- ctx.log("Metadata: " + ctx.metadata.toString());
- outMsg.value = inMsg;
-}
-
-// // A blob added to a container is copied to a queue
-@af:Function
-public isolated function fromBlobToQueue(af:Context ctx,
- @af:BlobTrigger { path: "bpath1/{name}" } byte[] blobIn,
- @af:BindingName { } string name,
- @af:QueueOutput { queueName: "queue3" } af:StringOutputBinding outMsg)
- returns error? {
- outMsg.value = "Name: " + name + " Content: " + blobIn.toString();
-}
-
-// // HTTP request to read a blob value
-@af:Function
-public isolated function httpTriggerBlobInput(@af:HTTPTrigger { } af:HTTPRequest req,
- @af:BlobInput { path: "bpath1/{Query.name}" } byte[]? blobIn)
- returns @af:HTTPOutput string {
- int length = 0;
- if blobIn is byte[] {
- length = blobIn.length();
- }
- return "Blob: " + req.query["name"].toString() + " Length: " +
- length.toString() + " Content: " + blobIn.toString();
-}
-
-// // HTTP request to add a new blob
-@af:Function
-public isolated function httpTriggerBlobOutput(@af:HTTPTrigger { } af:HTTPRequest req,
- @af:BlobOutput { path: "bpath1/{Query.name}" } af:StringOutputBinding bb)
- returns @af:HTTPOutput string|error {
- bb.value = req.body;
- return "Blob: " + req.query["name"].toString() + " Content: " +
- bb?.value.toString();
-}
-
-// // Sending an SMS
-@af:Function
-public isolated function sendSMS(@af:HTTPTrigger { } af:HTTPRequest req,
- @af:TwilioSmsOutput { fromNumber: "+12069845840" }
- af:TwilioSmsOutputBinding tb)
- returns @af:HTTPOutput string {
- tb.to = req.query["to"].toString();
- tb.body = req.body.toString();
- return "Message - to: " + tb?.to.toString() + " body: " + tb?.body.toString();
-}
-
-public type Person record {
- string id;
- string name;
- string country;
-};
-
-// // CosmosDB record trigger
-@af:Function
-public isolated function cosmosDBToQueue1(@af:CosmosDBTrigger {
- connectionStringSetting: "CosmosDBConnection", databaseName: "db1",
- collectionName: "c1" } Person[] req,
- @af:QueueOutput { queueName: "queue3" } af:StringOutputBinding outMsg) {
- outMsg.value = req.toString();
-}
-
-@af:Function
-public isolated function cosmosDBToQueue2(@af:CosmosDBTrigger {
- connectionStringSetting: "CosmosDBConnection", databaseName: "db1",
- collectionName: "c2" } json req,
- @af:QueueOutput { queueName: "queue3" } af:StringOutputBinding outMsg) {
- outMsg.value = req.toString();
-}
-
-// // HTTP request to read CosmosDB records
-@af:Function
-public isolated function httpTriggerCosmosDBInput1(
- @af:HTTPTrigger { } af:HTTPRequest httpReq,
- @af:CosmosDBInput { connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1",
- id: "{Query.id}", partitionKey: "{Query.country}" } json dbReq)
- returns @af:HTTPOutput string|error {
- return dbReq.toString();
-}
-
-@af:Function
-public isolated function httpTriggerCosmosDBInput2(
- @af:HTTPTrigger { } af:HTTPRequest httpReq,
- @af:CosmosDBInput { connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1",
- id: "{Query.id}", partitionKey: "{Query.country}" } Person? dbReq)
- returns @af:HTTPOutput string|error {
- return dbReq.toString();
-}
-
-@af:Function
-public isolated function httpTriggerCosmosDBInput3(
- @af:HTTPTrigger { route: "c1/{country}" } af:HTTPRequest httpReq,
- @af:CosmosDBInput { connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1",
- sqlQuery: "select * from c1 where c1.country = {country}" }
- Person[] dbReq)
- returns @af:HTTPOutput string|error {
- return dbReq.toString();
-}
-
-// // HTTP request to write records to CosmosDB
-@af:Function
-public isolated function httpTriggerCosmosDBOutput1(
- @af:HTTPTrigger { } af:HTTPRequest httpReq, @af:HTTPOutput af:HTTPBinding hb)
- returns @af:CosmosDBOutput { connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1" } json {
- json entry = { id: uuid:createType1AsString(), name: "Saman", country: "Sri Lanka" };
- hb.payload = "Adding entry: " + entry.toString();
- return entry;
-}
-
-@af:Function
-public isolated function httpTriggerCosmosDBOutput2(
- @af:HTTPTrigger { } af:HTTPRequest httpReq,
- @af:HTTPOutput af:HTTPBinding hb)
- returns @af:CosmosDBOutput {
- connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1" } json {
- json entry = [{ id: uuid:createType1AsString(), name: "John Doe A", country: "USA" },
- { id: uuid:createType1AsString(), name: "John Doe B", country: "USA" }];
- hb.payload = "Adding entries: " + entry.toString();
- return entry;
-}
-
-@af:Function
-public isolated function httpTriggerCosmosDBOutput3(
- @af:HTTPTrigger { } af:HTTPRequest httpReq)
- returns @af:CosmosDBOutput {
- connectionStringSetting: "CosmosDBConnection",
- databaseName: "db1", collectionName: "c1" } Person[] {
- Person[] persons = [];
- persons.push({id: uuid:createType1AsString(), name: "Jack", country: "UK"});
- persons.push({id: uuid:createType1AsString(), name: "Will", country: "UK"});
- return persons;
-}
-
-// // A timer function which is executed every 10 seconds.
-@af:Function
-public isolated function queuePopulationTimer(
- @af:TimerTrigger { schedule: "*/10 * * * * *" } json triggerInfo,
- @af:QueueOutput { queueName: "queue4" } af:StringOutputBinding msg) {
- msg.value = triggerInfo.toString();
-}
diff --git a/ballerina-tests/tests/main.bal b/ballerina-tests/tests/main.bal
new file mode 100644
index 00000000..4a6809ca
--- /dev/null
+++ b/ballerina-tests/tests/main.bal
@@ -0,0 +1,438 @@
+import ballerinax/azure_functions as af;
+import ballerina/http;
+
+public type DBEntry record {
+ string id;
+};
+
+public type Person record {
+ string name;
+ int age;
+};
+
+public type RateLimitHeaders record {|
+ int Content\-Length;
+ string Content\-Type;
+|};
+
+public type NoHeaderVal record {|
+ int Content\-Length;
+ string Content\-Type;
+ string Content\-Type1;
+|};
+
+listener af:HttpListener ep1 = new ();
+
+service /hello\- on ep1 {
+
+ resource function post hello\-query() returns string|error {
+ return "Hello from the hello-query";
+ }
+}
+
+listener af:HttpListener ep2 = new ();
+
+@http:ServiceConfig {
+ treatNilableAsOptional: false
+}
+service /httpHeader on ep2 {
+ resource function post nonTreatNilAsOpt\-Nil\-noHeaderTest(@http:Header string? hoste) returns string? {
+ return hoste;
+ }
+
+ resource function post nonTreatNilAsOpt\-nonNil\-noHeaderTest(@http:Header string hoste) returns string {
+ return hoste;
+
+ }
+
+ resource function post nonTreatNilAsOpt\-nonNil\-HeaderTest(@http:Header string hos) returns string {
+ return hos;
+
+ }
+
+ resource function post nonTreatNilAsOpt\-Nil\-HeaderTest(@http:Header string? hos) returns string? {
+ return hos;
+
+ }
+}
+
+listener af:HttpListener ep3 = new ();
+
+service /httpHeader on ep3 {
+ resource function post retrFromAnnotField(@http:Header {name: "Content-Type"} string contentType) returns string {
+
+ return contentType;
+ }
+
+ resource function post retrFromParam(@http:Header string Host) returns string {
+
+ return Host;
+
+ }
+
+ resource function post retrSingleVal(@http:Header {name: "Content-Length"} int contentLength) returns int {
+
+ return contentLength + 10;
+
+ }
+
+ resource function post retrArrVal(@http:Header {name: "Content-Length"} int[] contentLength) returns int {
+
+ return contentLength[0] + 15;
+
+ }
+
+ resource function post retrArrValStr(@http:Header string[] test) returns string {
+ return test[0];
+
+ }
+
+ resource function post retrAsRecord(@http:Header RateLimitHeaders rateLimiters) returns int {
+ return rateLimiters.Content\-Length + 100;
+
+ }
+
+ resource function post retrNilable(@http:Header string? Host) returns string? {
+ return Host;
+
+ }
+
+ resource function post treatNilAsOpt\-nonNil\-noHeaderTest(@http:Header string hoste) returns string {
+ return hoste;
+
+ }
+
+ resource function post treatNilAsOpt\-nonNil\-HeaderTest(@http:Header string hos) returns string {
+ return hos;
+
+ }
+
+ resource function post retrAsRecordNoField(@http:Header NoHeaderVal noHeaderVal) returns int {
+ return noHeaderVal.Content\-Length + 100;
+
+ }
+
+ resource function post treatNilAsOpt\-Nil\-noHeaderTest(@http:Header string? hoste) returns string? {
+ return hoste;
+
+ }
+
+ resource function post treatNilAsOpt\-Nil\-HeaderTest(@http:Header string? hos) returns string? {
+ return hos;
+
+ }
+}
+listener af:HttpListener ep = new ();
+
+service /hello on ep {
+
+ resource function default all() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function post optional/out(@http:Payload string greeting) returns string {
+ return "Hello from optional output binding";
+ }
+
+ resource function post optional/payload(@http:Payload string? greeting) returns string {
+ if (greeting is string) {
+ return "Hello, the payload found " + greeting;
+ }
+ return "Hello, the payload wasn't set but all good ;)";
+ }
+
+ resource function post .(@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from . path ";
+ }
+ resource function post httpResTest1(@http:Payload string greeting) returns @af:HttpOutput http:Unauthorized {
+ http:Unauthorized unauth = {
+ body: "Helloworld.....",
+ mediaType: "application/account+json",
+ headers: {
+ "Location": "/myServer/084230"
+ }
+ };
+ return unauth;
+ }
+
+ resource function post httpResTest2(@http:Payload string greeting) returns @af:HttpOutput http:Ok {
+ http:Ok ok = {body: "Helloworld....."};
+ return ok;
+ }
+ resource function post httpResTest3(@http:Payload string greeting) returns @af:HttpOutput http:InternalServerError {
+ http:InternalServerError err = {
+ body: "Helloworld.....",
+ headers: {
+ "Content-Type": "application/json+id",
+ "Location": "/myServer/084230"
+ }
+ };
+ return err;
+ }
+ resource function post httpResTest4(@http:Payload string greeting) returns @af:HttpOutput http:InternalServerError {
+ http:InternalServerError err = {};
+ return err;
+ }
+
+ resource function post foo(@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from foo path " + greeting;
+ }
+
+ resource function post foo/[string bar](@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from foo param " + bar;
+ }
+
+ resource function post foo/bar(@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from foo bar res";
+ }
+
+ resource function post db(@http:Payload string greeting, @af:CosmosDBInput {
+ connectionStringSetting: "CosmosDBConnection",
+ databaseName: "db1",
+ collectionName: "c2",
+ sqlQuery: "SELECT * FROM Items"
+ } DBEntry[] input1) returns @af:HttpOutput string|error {
+ return "Hello " + greeting + input1[0].id;
+ }
+
+ resource function post payload/jsonToRecord(@http:Payload Person greeting) returns @af:HttpOutput string|error {
+ return "Hello from json to record " + greeting.name;
+ }
+
+ resource function post payload/jsonToJson(@http:Payload json greeting) returns @af:HttpOutput string|error {
+ string name = check greeting.name;
+ return "Hello from json to json " + name;
+ }
+
+ resource function post payload/xmlToXml(@http:Payload xml greeting) returns @af:HttpOutput string|error {
+ return greeting.toJsonString();
+ }
+
+ resource function post payload/textToString(@http:Payload string greeting) returns @af:HttpOutput string|error {
+ return greeting;
+ }
+
+ resource function post payload/textToByte(@http:Payload byte[] greeting) returns @af:HttpOutput string|error {
+ return string:fromBytes(greeting);
+ }
+
+ resource function post payload/octaToByte(@http:Payload byte[] greeting) returns @af:HttpOutput string|error {
+ return string:fromBytes(greeting);
+ }
+
+ resource function get err/empty/payload(@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from get empty payload";
+ }
+
+ resource function post err/invalid/payload(@http:Payload string greeting) returns @af:HttpOutput string {
+ return "Hello from get invalid payload " + greeting;
+ }
+
+ resource function get httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function put httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function patch httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function delete httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function head httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function options httpAccessorTest() returns @af:HttpOutput string {
+ return "Hello from all";
+ }
+
+ resource function post httpResTest5() returns http:StatusCodeResponse {
+ http:InternalServerError err = {};
+ return err;
+ }
+
+ resource function post nonHttpResTest1() returns string {
+ string s1 = "alpha";
+ return s1;
+ }
+
+ resource function post nonHttpResTest2() returns xml {
+ xml x1 = xml `The Lost World`;
+ return x1;
+ }
+
+ resource function post nonHttpResTest3() returns byte[] {
+ byte[] b1 = base64 `yPHaytRgJPg+QjjylUHakEwz1fWPx/wXCW41JSmqYW8=`;
+ return b1;
+
+ }
+
+ resource function post nonHttpResTest4() returns int {
+ int i1 = 100;
+ return i1;
+ }
+
+ resource function post nonHttpResTest6() returns decimal {
+ decimal d1 = 100;
+ return d1;
+ }
+
+ resource function post nonHttpResTest7() returns boolean {
+ boolean bo1 = true;
+ return bo1;
+ }
+
+ resource function post nonHttpResTest8() returns map {
+ map mj1 = {"a": {"b": 12, "c": "helloworld"}};
+ return mj1;
+
+ }
+
+ resource function post nonHttpResTest9() returns table