Skip to content

[skip changelog] Demonstrate gRPC interface's LibraryResolveDependencies method in client_example #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion client_example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ require (
github.com/arduino/arduino-cli v0.0.0-20200109150215-ffa84fdaab21
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282 // indirect
google.golang.org/grpc v1.23.0
)
)
24 changes: 24 additions & 0 deletions client_example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ func main() {
log.Println("calling LibrarySearch(audio)")
callLibSearch(client, instance)

// List the dependencies of the ArduinoIoTCloud library
log.Println("calling LibraryResolveDependencies(ArduinoIoTCloud)")
callLibraryResolveDependencies(client, instance)

// List installed libraries
log.Println("calling LibraryList")
callLibList(client, instance)
Expand Down Expand Up @@ -734,6 +738,26 @@ func callLibSearch(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
}
}

func callLibraryResolveDependencies(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
libraryResolveDependenciesResp, err := client.LibraryResolveDependencies(context.Background(),
&rpc.LibraryResolveDependenciesReq{
Instance: instance,
Name: "ArduinoIoTCloud",
})

if err != nil {
log.Fatalf("Error listing library dependencies: %s", err)
}

for _, resp := range libraryResolveDependenciesResp.GetDependencies() {
log.Printf("Dependency Name: %s", resp.GetName())
log.Printf("Version Required: %s", resp.GetVersionRequired())
if resp.GetVersionInstalled() != "" {
log.Printf("Version Installed: %s\n", resp.GetVersionInstalled())
}
}
}

func callLibList(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
libLstResp, err := client.LibraryList(context.Background(),
&rpc.LibraryListReq{
Expand Down