syntax = "proto3";

package worldmonitor.infrastructure.v1;

import "sebuf/http/annotations.proto";
import "worldmonitor/infrastructure/v1/get_bootstrap_data.proto";
import "worldmonitor/infrastructure/v1/get_cable_health.proto";
import "worldmonitor/infrastructure/v1/get_ip_geo.proto";
import "worldmonitor/infrastructure/v1/get_temporal_baseline.proto";
import "worldmonitor/infrastructure/v1/list_internet_ddos_attacks.proto";
import "worldmonitor/infrastructure/v1/list_internet_outages.proto";
import "worldmonitor/infrastructure/v1/list_internet_traffic_anomalies.proto";
import "worldmonitor/infrastructure/v1/list_service_statuses.proto";
import "worldmonitor/infrastructure/v1/list_temporal_anomalies.proto";
import "worldmonitor/infrastructure/v1/record_baseline_snapshot.proto";
import "worldmonitor/infrastructure/v1/reverse_geocode.proto";

// InfrastructureService provides APIs for internet outage monitoring from Cloudflare Radar,
// external service status tracking, and temporal baseline anomaly detection.
service InfrastructureService {
  option (sebuf.http.service_config) = {base_path: "/api/infrastructure/v1"};

  // ListInternetOutages retrieves detected internet outages from Cloudflare Radar.
  rpc ListInternetOutages(ListInternetOutagesRequest) returns (ListInternetOutagesResponse) {
    option (sebuf.http.config) = {
      path: "/list-internet-outages"
      method: HTTP_METHOD_GET
    };
  }

  // ListServiceStatuses retrieves operational status of monitored external services.
  rpc ListServiceStatuses(ListServiceStatusesRequest) returns (ListServiceStatusesResponse) {
    option (sebuf.http.config) = {
      path: "/list-service-statuses"
      method: HTTP_METHOD_GET
    };
  }

  // GetTemporalBaseline retrieves historical baseline data for a specific signal.
  rpc GetTemporalBaseline(GetTemporalBaselineRequest) returns (GetTemporalBaselineResponse) {
    option (sebuf.http.config) = {
      path: "/get-temporal-baseline"
      method: HTTP_METHOD_GET
    };
  }

  // GetIpGeo retrieves geographic information based on the caller's IP address.
  rpc GetIpGeo(GetIpGeoRequest) returns (GetIpGeoResponse) {
    option (sebuf.http.config) = {
      path: "/get-ip-geo"
      method: HTTP_METHOD_GET
    };
  }

  // ReverseGeocode resolves geographic coordinates to a postal address/country.
  rpc ReverseGeocode(ReverseGeocodeRequest) returns (ReverseGeocodeResponse) {
    option (sebuf.http.config) = {
      path: "/reverse-geocode"
      method: HTTP_METHOD_GET
    };
  }

  // GetBootstrapData fetches multiple data points from the system cache in a single call.
  rpc GetBootstrapData(GetBootstrapDataRequest) returns (GetBootstrapDataResponse) {
    option (sebuf.http.config) = {
      path: "/get-bootstrap-data"
      method: HTTP_METHOD_GET
    };
  }

  // RecordBaselineSnapshot batch-updates baseline statistics using Welford's online algorithm.
  rpc RecordBaselineSnapshot(RecordBaselineSnapshotRequest) returns (RecordBaselineSnapshotResponse) {
    option (sebuf.http.config) = {path: "/record-baseline-snapshot"};
  }

  // GetCableHealth computes health status for submarine cables from NGA maritime warning signals.
  rpc GetCableHealth(GetCableHealthRequest) returns (GetCableHealthResponse) {
    option (sebuf.http.config) = {
      path: "/get-cable-health"
      method: HTTP_METHOD_GET
    };
  }

  // ListTemporalAnomalies returns server-computed temporal anomalies for news and satellite_fires.
  rpc ListTemporalAnomalies(ListTemporalAnomaliesRequest) returns (ListTemporalAnomaliesResponse) {
    option (sebuf.http.config) = {
      path: "/list-temporal-anomalies"
      method: HTTP_METHOD_GET
    };
  }

  // ListInternetDdosAttacks retrieves L3/L4 DDoS attack summaries from Cloudflare Radar.
  rpc ListInternetDdosAttacks(ListInternetDdosAttacksRequest) returns (ListInternetDdosAttacksResponse) {
    option (sebuf.http.config) = {
      path: "/list-internet-ddos-attacks"
      method: HTTP_METHOD_GET
    };
  }

  // ListInternetTrafficAnomalies retrieves traffic anomaly events from Cloudflare Radar.
  rpc ListInternetTrafficAnomalies(ListInternetTrafficAnomaliesRequest) returns (ListInternetTrafficAnomaliesResponse) {
    option (sebuf.http.config) = {
      path: "/list-internet-traffic-anomalies"
      method: HTTP_METHOD_GET
    };
  }
}
