mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
Generate clients (#206)
This commit is contained in:
7
examples/file/delete/curl/deleteFile.sh
Executable file
7
examples/file/delete/curl/deleteFile.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/file/Delete" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}'
|
||||
17
examples/file/delete/go/deleteFile.go
Executable file
17
examples/file/delete/go/deleteFile.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Delete a file by project name/path
|
||||
func DeleteFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.Delete(&file.DeleteRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/file/delete/node/deleteFile.js
Executable file
13
examples/file/delete/node/deleteFile.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Delete a file by project name/path
|
||||
async function DeleteFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.delete({
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await DeleteFile();
|
||||
6
examples/file/list/curl/listFiles.sh
Executable file
6
examples/file/list/curl/listFiles.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl "https://api.m3o.com/v1/file/List" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"project": "examples"
|
||||
}'
|
||||
16
examples/file/list/go/listFiles.go
Executable file
16
examples/file/list/go/listFiles.go
Executable file
@@ -0,0 +1,16 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func ListFiles() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.List(&file.ListRequest{
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
12
examples/file/list/node/listFiles.js
Executable file
12
examples/file/list/node/listFiles.js
Executable file
@@ -0,0 +1,12 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
async function ListFiles() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.list({
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ListFiles();
|
||||
7
examples/file/read/curl/readFile.sh
Executable file
7
examples/file/read/curl/readFile.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
curl "https://api.m3o.com/v1/file/Read" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}'
|
||||
17
examples/file/read/go/readFile.go
Executable file
17
examples/file/read/go/readFile.go
Executable file
@@ -0,0 +1,17 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Read a file by path
|
||||
func ReadFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.Read(&file.ReadRequest{
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
13
examples/file/read/node/readFile.js
Executable file
13
examples/file/read/node/readFile.js
Executable file
@@ -0,0 +1,13 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Read a file by path
|
||||
async function ReadFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.read({
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await ReadFile();
|
||||
10
examples/file/save/curl/saveFile.sh
Executable file
10
examples/file/save/curl/saveFile.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
curl "https://api.m3o.com/v1/file/Save" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||
-d '{
|
||||
"file": {
|
||||
"content": "file content example",
|
||||
"path": "/document/text-files/file.txt",
|
||||
"project": "examples"
|
||||
}
|
||||
}'
|
||||
20
examples/file/save/go/saveFile.go
Executable file
20
examples/file/save/go/saveFile.go
Executable file
@@ -0,0 +1,20 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/micro/services/clients/go/file"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Save a file
|
||||
func SaveFile() {
|
||||
fileService := file.NewFileService(os.Getenv("MICRO_API_TOKEN"))
|
||||
rsp, err := fileService.Save(&file.SaveRequest{
|
||||
File: &file.Record{
|
||||
Content: "file content example",
|
||||
Path: "/document/text-files/file.txt",
|
||||
Project: "examples",
|
||||
},
|
||||
})
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
16
examples/file/save/node/saveFile.js
Executable file
16
examples/file/save/node/saveFile.js
Executable file
@@ -0,0 +1,16 @@
|
||||
import * as file from "m3o/file";
|
||||
|
||||
// Save a file
|
||||
async function SaveFile() {
|
||||
let fileService = new file.FileService(process.env.MICRO_API_TOKEN);
|
||||
let rsp = await fileService.save({
|
||||
file: {
|
||||
content: "file content example",
|
||||
path: "/document/text-files/file.txt",
|
||||
project: "examples",
|
||||
},
|
||||
});
|
||||
console.log(rsp);
|
||||
}
|
||||
|
||||
await SaveFile();
|
||||
Reference in New Issue
Block a user