diff --git a/client_example/go.mod b/client_example/go.mod index 8002361f14f..91cc576487c 100644 --- a/client_example/go.mod +++ b/client_example/go.mod @@ -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 -) +) \ No newline at end of file diff --git a/client_example/main.go b/client_example/main.go index 5361544c38f..b67e3f5de55 100644 --- a/client_example/main.go +++ b/client_example/main.go @@ -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) @@ -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{