// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

syntax = "proto3";

package supervisor;

import "google/api/annotations.proto";

option go_package = "github.com/gitpod-io/gitpod/supervisor/api";

service InfoService {
    rpc WorkspaceInfo(WorkspaceInfoRequest) returns (WorkspaceInfoResponse) {
        option (google.api.http) = {
            get: "/v1/info/workspace"
        };
    }
}

message WorkspaceInfoRequest {}

message WorkspaceInfoResponse {
    message GitpodAPI {
        // endpoint is the websocket URL on which the token-accessible Gitpod API is served on
        string endpoint = 1;
        // host is the host of the endpoint. Use this host to ask supervisor a token.
        string host = 2;
    }

    // workspace_id is the workspace ID of this workspace.
    string workspace_id = 1;

    // instance_id is the instance ID of this workspace.
    string instance_id = 2;

    // checkout_location is the path where we initialized the workspace content
    string checkout_location = 3;

    // workspace_location is the location of the IDE workspace
    oneof workspace_location {
        // file means the workspace root is a file describing the workspace layout.
        string workspace_location_file = 4;
        // folder means the workspace root is a simple folder.
        string workspace_location_folder = 5;
    };

    // user_home is the path to the user's home.
    string user_home = 6;

    // GitpodAPI provides information to reach the Gitpod server API.
    GitpodAPI gitpod_api = 7;

    // gitpod_host provides Gitpod host URL.
    string gitpod_host = 8;

    // workspace_context_url is an URL for which the workspace was created.
    string workspace_context_url = 9;

    message Repository {
        // owner is the repository owner
        string owner = 1;
        // name is the repository name
        string name = 2;
    }
    // repository is a repository from which this workspace was created
    Repository repository = 10;
}
