// Copyright 2020 Prysmatic Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

package ethereum.eth.service;

import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/empty.proto";

import "proto/eth/v1/node.proto";

option csharp_namespace = "Ethereum.Eth.Service";
option go_package = "github.com/prysmaticlabs/prysm/proto/eth/service";
option java_multiple_files = true;
option java_outer_classname = "NodeServiceProto";
option java_package = "org.ethereum.eth.service";
option php_namespace = "Ethereum\\Eth\\Service";

// Beacon chain node API
//
// The beacon chain node API is a set of endpoints to query node information.
service BeaconNode {
  // GetIdentity retrieves data about the node's network presence.
  rpc GetIdentity(google.protobuf.Empty) returns (v1.IdentityResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/identity"};
  }

  // ListPeers retrieves data about the node's network peers.
  rpc ListPeers(v1.PeersRequest) returns (v1.PeersResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/peers"};
  }

  // GetPeer retrieves data about the given peer.
  rpc GetPeer(v1.PeerRequest) returns (v1.PeerResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/peers/{peer_id}"};
  }

  // PeerCount retrieves number of known peers.
  rpc PeerCount(google.protobuf.Empty) returns (v1.PeerCountResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/peer_count"};
  }

  // GetSyncStatus requests the beacon node to describe if it's currently syncing or not, and
  // if it is, what block it is up to.
  rpc GetSyncStatus(google.protobuf.Empty) returns (v1.SyncingResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/syncing"};
  }

  // GetVersion requests that the beacon node identify information about its implementation in a
  // format similar to a HTTP User-Agent field.
  rpc GetVersion(google.protobuf.Empty) returns (v1.VersionResponse) {
    option (google.api.http) = {get: "/internal/eth/v1/node/version"};
  }

  // GetHealth returns node health status in http status codes. Useful for load balancers.
  // Response Usage:
  //    "200":
  //      description: Node is ready
  //    "206":
  //      description: Node is syncing but can serve incomplete data
  //    "503":
  //      description: Node not initialized or having issues
  rpc GetHealth(google.protobuf.Empty) returns (google.protobuf.Empty) {
    option (google.api.http) = {get: "/internal/eth/v1/node/health"};
  }
}
