// This file is part of arduino-cli.
//
// Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

syntax = "proto3";

package cc.arduino.cli.commands.v1;

option go_package = "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1;commands";

import "cc/arduino/cli/commands/v1/common.proto";

message PlatformInstallRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // Vendor name of the platform (e.g., `arduino`).
  string platform_package = 2;
  // Architecture name of the platform (e.g., `avr`).
  string architecture = 3;
  // Platform version to install.
  string version = 4;
  // Set to true to not run (eventual) post install scripts for trusted
  // platforms
  bool skip_post_install = 5;
}

message PlatformInstallResponse {
  // Progress of the downloads of the platform and tool files.
  DownloadProgress progress = 1;
  // Description of the current stage of the installation.
  TaskProgress task_progress = 2;
}

message PlatformDownloadRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  string platform_package = 2;
  // Architecture name of the platform (e.g., `avr`).
  string architecture = 3;
  // Platform version to download.
  string version = 4;
}

message PlatformDownloadResponse {
  // Progress of the downloads of platform and tool files.
  DownloadProgress progress = 1;
}

message PlatformUninstallRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // Vendor name of the platform (e.g., `arduino`).
  string platform_package = 2;
  // Architecture name of the platform (e.g., `avr`).
  string architecture = 3;
}

message PlatformUninstallResponse {
  // Description of the current stage of the uninstall.
  TaskProgress task_progress = 1;
}

// AlreadyAtLatestVersionError is returned when an upgrade is not possible
// because already at latest version.
message AlreadyAtLatestVersionError {}

message PlatformUpgradeRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // Vendor name of the platform (e.g., `arduino`).
  string platform_package = 2;
  // Architecture name of the platform (e.g., `avr`).
  string architecture = 3;
  // Set to true to not run (eventual) post install scripts for trusted
  // platforms
  bool skip_post_install = 4;
}

message PlatformUpgradeResponse {
  // Progress of the downloads of the platform and tool files.
  DownloadProgress progress = 1;
  // Description of the current stage of the upgrade.
  TaskProgress task_progress = 2;
}

message PlatformSearchRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // Keywords for the search.
  string search_args = 2;
  // Whether to show all available versions. `false` causes only the newest
  // versions of the cores to be listed in the search results.
  bool all_versions = 3;
}

message PlatformSearchResponse {
  // Results of the search.
  repeated Platform search_output = 1;
}

message PlatformListRequest {
  // Arduino Core Service instance from the `Init` response.
  Instance instance = 1;
  // Set to true to only list platforms which have a newer version available
  // than the one currently installed.
  bool updatable_only = 2;
  // Set to true to list platforms installed manually in the user' sketchbook
  // hardware folder, installed with the PlatformManager through the CLI or
  // IDE and that are available to install
  bool all = 3;
}

message PlatformListResponse {
  // The installed platforms.
  repeated Platform installed_platforms = 1;
}
