@@ -29,7 +29,6 @@ import (
2929 "time"
3030
3131 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
32- "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/settings/v1"
3332 "google.golang.org/grpc"
3433 "google.golang.org/grpc/credentials/insecure"
3534)
@@ -63,8 +62,6 @@ func main() {
6362 // Create an instance of the gRPC clients.
6463 client := rpc .NewArduinoCoreServiceClient (conn )
6564
66- settingsClient := settings .NewSettingsServiceClient (conn )
67-
6865 // Now we can call various methods of the API...
6966
7067 // `Version` can be called without any setup or init procedure.
@@ -76,39 +73,39 @@ func main() {
7673
7774 // Use SetValue to configure the arduino-cli directories.
7875 log .Println ("calling SetValue" )
79- callSetValue (settingsClient )
76+ callSetValue (client )
8077
81- // List all the settings.
82- log .Println ("calling GetAll ()" )
83- callGetAll (settingsClient )
78+ // List all settings
79+ log .Println ("calling SettingsGetAll ()" )
80+ callGetAll (client )
8481
8582 // Merge applies multiple settings values at once.
86- log .Println ("calling Merge ()" )
87- callMerge (settingsClient , `{"foo": {"value": "bar"}, "daemon":{"port":"422"}, "board_manager": {"additional_urls":["https://example.com"]}}` )
83+ log .Println ("calling SettingsMerge ()" )
84+ callMerge (client , `{"foo": {"value": "bar"}, "daemon":{"port":"422"}, "board_manager": {"additional_urls":["https://example.com"]}}` )
8885
89- log .Println ("calling GetAll ()" )
90- callGetAll (settingsClient )
86+ log .Println ("calling SettingsGetAll ()" )
87+ callGetAll (client )
9188
92- log .Println ("calling Merge ()" )
93- callMerge (settingsClient , `{"foo": {} }` )
89+ log .Println ("calling SettingsMerge ()" )
90+ callMerge (client , `{"foo": {} }` )
9491
95- log .Println ("calling GetAll ()" )
96- callGetAll (settingsClient )
92+ log .Println ("calling SettingsGetAll ()" )
93+ callGetAll (client )
9794
98- log .Println ("calling Merge ()" )
99- callMerge (settingsClient , `{"foo": "bar" }` )
95+ log .Println ("calling SettingsMerge ()" )
96+ callMerge (client , `{"foo": "bar" }` )
10097
10198 // Get the value of the foo key.
102- log .Println ("calling GetValue (foo)" )
103- callGetValue (settingsClient )
99+ log .Println ("calling SettingsGetValue (foo)" )
100+ callGetValue (client )
104101
105- // List all the settings.
106- log .Println ("calling GetAll ()" )
107- callGetAll (settingsClient )
102+ // List all settings
103+ log .Println ("calling SettingsGetAll ()" )
104+ callGetAll (client )
108105
109106 // Write settings to file.
110107 log .Println ("calling Write()" )
111- callWrite (settingsClient )
108+ callWrite (client )
112109
113110 // Before we can do anything with the CLI, an "instance" must be created.
114111 // We keep a reference to the created instance because we will need it to
@@ -121,7 +118,7 @@ func main() {
121118
122119 // We set up the proxy and then run the update to verify that the proxy settings are currently used
123120 log .Println ("calling setProxy" )
124- callSetProxy (settingsClient )
121+ callSetProxy (client )
125122
126123 // With a brand new instance, the first operation should always be updating
127124 // the index.
@@ -247,22 +244,21 @@ func callVersion(client rpc.ArduinoCoreServiceClient) {
247244 log .Printf ("arduino-cli version: %v" , versionResp .GetVersion ())
248245}
249246
250- func callSetValue (client settings. SettingsServiceClient ) {
251- _ , err := client .SetValue (context .Background (),
252- & settings. SetValueRequest {
247+ func callSetValue (client rpc. ArduinoCoreServiceClient ) {
248+ _ , err := client .SettingsSetValue (context .Background (),
249+ & rpc. SettingsSetValueRequest {
253250 Key : "directories" ,
254251 JsonData : `{"data": "` + dataDir + `", "downloads": "` + path .Join (dataDir , "staging" ) + `", "user": "` + path .Join (dataDir , "sketchbook" ) + `"}` ,
255252 })
256253
257254 if err != nil {
258255 log .Fatalf ("Error setting settings value: %s" , err )
259-
260256 }
261257}
262258
263- func callSetProxy (client settings. SettingsServiceClient ) {
264- _ , err := client .SetValue (context .Background (),
265- & settings. SetValueRequest {
259+ func callSetProxy (client rpc. ArduinoCoreServiceClient ) {
260+ _ , err := client .SettingsSetValue (context .Background (),
261+ & rpc. SettingsSetValueRequest {
266262 Key : "network.proxy" ,
267263 JsonData : `"http://localhost:3128"` ,
268264 })
@@ -272,9 +268,9 @@ func callSetProxy(client settings.SettingsServiceClient) {
272268 }
273269}
274270
275- func callUnsetProxy (client settings. SettingsServiceClient ) {
276- _ , err := client .SetValue (context .Background (),
277- & settings. SetValueRequest {
271+ func callUnsetProxy (client rpc. ArduinoCoreServiceClient ) {
272+ _ , err := client .SettingsSetValue (context .Background (),
273+ & rpc. SettingsSetValueRequest {
278274 Key : "network.proxy" ,
279275 JsonData : `""` ,
280276 })
@@ -284,9 +280,9 @@ func callUnsetProxy(client settings.SettingsServiceClient) {
284280 }
285281}
286282
287- func callMerge (client settings. SettingsServiceClient , jsonData string ) {
288- _ , err := client .Merge (context .Background (),
289- & settings. MergeRequest {
283+ func callMerge (client rpc. ArduinoCoreServiceClient , jsonData string ) {
284+ _ , err := client .SettingsMerge (context .Background (),
285+ & rpc. SettingsMergeRequest {
290286 JsonData : jsonData ,
291287 })
292288
@@ -295,9 +291,9 @@ func callMerge(client settings.SettingsServiceClient, jsonData string) {
295291 }
296292}
297293
298- func callGetValue (client settings. SettingsServiceClient ) {
299- getValueResp , err := client .GetValue (context .Background (),
300- & settings. GetValueRequest {
294+ func callGetValue (client rpc. ArduinoCoreServiceClient ) {
295+ getValueResp , err := client .SettingsGetValue (context .Background (),
296+ & rpc. SettingsGetValueRequest {
301297 Key : "foo" ,
302298 })
303299
@@ -308,8 +304,8 @@ func callGetValue(client settings.SettingsServiceClient) {
308304 log .Printf ("Value: %s: %s" , getValueResp .GetKey (), getValueResp .GetJsonData ())
309305}
310306
311- func callGetAll (client settings. SettingsServiceClient ) {
312- getAllResp , err := client .GetAll (context .Background (), & settings. GetAllRequest {})
307+ func callGetAll (client rpc. ArduinoCoreServiceClient ) {
308+ getAllResp , err := client .SettingsGetAll (context .Background (), & rpc. SettingsGetAllRequest {})
313309
314310 if err != nil {
315311 log .Fatalf ("Error getting settings: %s" , err )
@@ -318,10 +314,10 @@ func callGetAll(client settings.SettingsServiceClient) {
318314 log .Printf ("Settings: %s" , getAllResp .GetJsonData ())
319315}
320316
321- func callWrite (client settings. SettingsServiceClient ) {
322- _ , err := client .Write (context .Background (),
323- & settings. WriteRequest {
324- FilePath : path .Join (dataDir , "written-settings.yml " ),
317+ func callWrite (client rpc. ArduinoCoreServiceClient ) {
318+ _ , err := client .SettingsWrite (context .Background (),
319+ & rpc. SettingsWriteRequest {
320+ FilePath : path .Join (dataDir , "written-rpc.Settingsyml " ),
325321 })
326322
327323 if err != nil {
0 commit comments