mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
Function service (#227)
This commit is contained in:
7
examples/function/call/curl/callAFunction.sh
Executable file
7
examples/function/call/curl/callAFunction.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/function/Call" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"name": "my-first-func",
|
||||
"request": {}
|
||||
}'
|
||||
17
examples/function/call/go/callAFunction.go
Executable file
17
examples/function/call/go/callAFunction.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/function"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Call a function
|
||||
func CallAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := functionService.Call(&function.CallRequest{
|
||||
Name: "my-first-func",
|
||||
Request: map[string]interface{}{},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/function/call/node/callAFunction.js
Executable file
13
examples/function/call/node/callAFunction.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as fx from "m3o/function";
|
||||
|
||||
// Call a function
|
||||
async function CallAfunction() {
|
||||
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await functionService.call({
|
||||
name: "my-first-func",
|
||||
request: {},
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await CallAfunction();
|
||||
7
examples/function/delete/curl/deleteAFunction.sh
Executable file
7
examples/function/delete/curl/deleteAFunction.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/function/Delete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"name": "my-first-func",
|
||||
"project": "tests"
|
||||
}'
|
||||
17
examples/function/delete/go/deleteAFunction.go
Executable file
17
examples/function/delete/go/deleteAFunction.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/function"
|
||||
"os"
|
||||
)
|
||||
|
||||
//
|
||||
func DeleteAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := functionService.Delete(&function.DeleteRequest{
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/function/delete/node/deleteAFunction.js
Executable file
13
examples/function/delete/node/deleteAFunction.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as fx from "m3o/function";
|
||||
|
||||
//
|
||||
async function DeleteAfunction() {
|
||||
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await functionService.delete({
|
||||
name: "my-first-func",
|
||||
project: "tests",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeleteAfunction();
|
||||
9
examples/function/deploy/curl/deployAFunction.sh
Executable file
9
examples/function/deploy/curl/deployAFunction.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
curl "https://api.m3o.com/v1/function/Deploy" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"entrypoint": "helloworld",
|
||||
"name": "my-first-func",
|
||||
"project": "tests",
|
||||
"repo": "github.com/crufter/gcloud-nodejs-test"
|
||||
}'
|
||||
19
examples/function/deploy/go/deployAFunction.go
Executable file
19
examples/function/deploy/go/deployAFunction.go
Executable file
@@ -0,0 +1,19 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/function"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Deploy a group of functions
|
||||
func DeployAfunction() {
|
||||
functionService := function.NewFunctionService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := functionService.Deploy(&function.DeployRequest{
|
||||
Entrypoint: "helloworld",
|
||||
Name: "my-first-func",
|
||||
Project: "tests",
|
||||
Repo: "github.com/crufter/gcloud-nodejs-test",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
15
examples/function/deploy/node/deployAFunction.js
Executable file
15
examples/function/deploy/node/deployAFunction.js
Executable file
@@ -0,0 +1,15 @@
|
||||
import * as fx from "m3o/function";
|
||||
|
||||
// Deploy a group of functions
|
||||
async function DeployAfunction() {
|
||||
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await functionService.deploy({
|
||||
entrypoint: "helloworld",
|
||||
name: "my-first-func",
|
||||
project: "tests",
|
||||
repo: "github.com/crufter/gcloud-nodejs-test",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeployAfunction();
|
||||
4
examples/function/list/curl/listFunctions.sh
Executable file
4
examples/function/list/curl/listFunctions.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
curl "https://api.m3o.com/v1/function/List" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{}'
|
||||
14
examples/function/list/go/listFunctions.go
Executable file
14
examples/function/list/go/listFunctions.go
Executable file
@@ -0,0 +1,14 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/function"
|
||||
"os"
|
||||
)
|
||||
|
||||
//
|
||||
func ListFunctions() {
|
||||
functionService := function.NewFunctionService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := functionService.List(&function.ListRequest{})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
10
examples/function/list/node/listFunctions.js
Executable file
10
examples/function/list/node/listFunctions.js
Executable file
@@ -0,0 +1,10 @@
|
||||
import * as fx from "m3o/function";
|
||||
|
||||
//
|
||||
async function ListFunctions() {
|
||||
let functionService = new fx.FunctionService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await functionService.list({});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ListFunctions();
|
||||
Reference in New Issue
Block a user