// 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;

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

import "commands/common.proto";

message LibraryDownloadReq {
    Instance instance = 1;
    string name = 2;
    string version = 3;
}

message LibraryDownloadResp {
    DownloadProgress progress = 1;
}

message LibraryInstallReq {
    Instance instance = 1;
    string name = 2;
    string version = 3;
}

message LibraryInstallResp {
    DownloadProgress progress = 1;
    TaskProgress task_progress = 2;
}

message LibraryUninstallReq {
    Instance instance = 1;
    string name = 2;
    string version = 3;
}

message LibraryUninstallResp {
    TaskProgress task_progress = 1;
}

message LibraryUpgradeAllReq {
    Instance instance = 1;
}

message LibraryUpgradeAllResp {
    DownloadProgress progress = 1;
    TaskProgress task_progress = 2;
}

message LibraryResolveDependenciesReq {
    Instance instance = 1;
    string name = 2;
    string version = 3;
}

message LibraryResolveDependenciesResp {
    repeated LibraryDependencyStatus dependencies = 1;
}

message LibraryDependencyStatus {
    string name = 1;
    string versionRequired = 2;
    string versionInstalled = 3;
}

message LibrarySearchReq {
    Instance instance = 1;
    string query = 2;
}

enum LibrarySearchStatus {
    failed = 0;
    success = 1;
}

message LibrarySearchResp {
    repeated SearchedLibrary libraries = 1;
    LibrarySearchStatus status = 2;
}

message SearchedLibrary {
    string name = 1;
    map<string, LibraryRelease> releases = 2;
    LibraryRelease latest = 3;
}

message LibraryRelease {
    string author = 1;
    string version = 2;
    string maintainer = 3;
    string sentence = 4;
    string paragraph = 5;
    string website = 6;
    string category = 7;
    repeated string architectures = 8;
    repeated string types = 9;
    DownloadResource resources = 10;
    string license = 11;
    repeated string provides_includes = 12;
    repeated LibraryDependency dependencies = 13;
}

message LibraryDependency {
    string name = 1;
    string version_constraint = 2;
}

message DownloadResource {
    string url = 1;
    string archivefilename = 2;
    string checksum = 3;
    int64  size = 4;
    string cachepath = 5;
}

message LibraryListReq {
    Instance instance = 1;
    bool all = 2;
	bool updatable = 3;
}

message LibraryListResp {
    repeated InstalledLibrary installed_library = 1;
}

message InstalledLibrary {
    Library library = 1;
    LibraryRelease release = 2;
}

message Library {
    string name = 1;
    string author = 2;
    string maintainer = 3;
    string sentence = 4;
    string paragraph = 5;
    string website = 6;
    string category = 7;
    repeated string architectures = 8;
    repeated string types = 9;
    string install_dir = 10;
    string source_dir = 11;
    string utility_dir = 12;
    string container_platform = 14;
    string real_name = 16;
    bool dot_a_linkage = 17;
    bool precompiled = 18;
    string ld_flags = 19;
    bool is_legacy = 20;
    string version = 21;
    string license = 22;
    map<string, string> properties = 23;
    LibraryLocation location = 24;
    LibraryLayout layout = 25;
}

enum LibraryLayout {
    flat_layout = 0;
    recursive_layout = 1;
}

enum LibraryLocation {
    ide_builtin = 0;
    user = 1; // (sketchbook)
    platform_builtin = 2;
    referenced_platform_builtin = 3;
}
