/*
Copyright 2024 Google LLC

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

    https://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 workloadagentplatform.sharedprotos.datawarehouse;

import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "sharedprotos/status/status.proto";
import "sharedprotos/system/system.proto";

option go_package = "github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos/datawarehouse";

// Request for sending the data insights.
message WriteInsightRequest {
  reserved 4;
  // The GCP location.
  // The format is: projects/{project}/locations/{location}.
  string location = 1;
  // The metrics data details.
  Insight insight = 2;
  // An optional request ID to identify requests.
  string request_id = 3;
  // The agent version collected this data point.
  string agent_version = 5;
}

// A presentation of host resource usage where the workload runs.
message Insight {
  // [Output only] Create time stamp
  google.protobuf.Timestamp sent_time = 1;

  // The insights data for the SAP workload validation.
  SapValidation sap_validation = 2;

  // The insights data for SAP system discovery. This is a copy of SAP System
  // proto and should get updated whenever that one changes.
  workloadagentplatform.sharedprotos.system.SapDiscovery sap_discovery = 3;

  string sqlserver_validation = 4;

  // The instance id where the insight is generated from
  string instance_id = 5;

  // The insights data for workload validation of torso workloads.
  TorsoValidation torso_validation = 6;

  // The status of the agent and services (process metrics, host metrics, etc).
  workloadagentplatform.sharedprotos.status.AgentStatus agent_status = 7;

  // The insights data for workload validation of openshift workloads.
  OpenShiftValidation open_shift_validation = 8;
}

// A presentation of SAP workload insight.
// The schema of SAP workloads validation related data.
message SapValidation {
  // The different SAP validation types.
  enum SapValidationType {
    // Unspecified type.
    SAP_VALIDATION_TYPE_UNSPECIFIED = 0;
    // The SYSTEM validation type collects underlying system data from the VM.
    SYSTEM = 1;
    // The COROSYNC validation type collects Corosync configuration and runtime
    // data. Corosync enables servers to interact as a HA cluster.
    COROSYNC = 2;
    // The PACEMAKER validation type collects Pacemaker configuration data.
    // Pacemaker is a high-availability cluster resource manager.
    PACEMAKER = 3;
    // The HANA validation type collects HANA configuration data. SAP HANA is an
    // in-memory, column-oriented, relational database management system.
    HANA = 4;
    // The NETWEAVER validation type collects NetWeaver configuration data. SAP
    // NetWeaver is a software stack for many of SAP SE's applications.
    NETWEAVER = 5;
    // The HANA_SECURITY validation type collects HANA configuration data as it
    // relates to SAP security best practices.
    HANA_SECURITY = 6;
    // The CUSTOM validation type collects any customer-defined data that does
    // not fall into any of the other categories of validations.
    CUSTOM = 7;
  }
  // Message describing the SAP validation metrics.
  message ValidationDetail {
    // The SAP system that the validation data is from.
    SapValidationType sap_validation_type = 1;
    // The <k,v> pairs of metrics data: field name & field value.
    map<string, string> details = 2;
    // Was there a SAP system detected for this validation type.
    bool is_present = 3;
  }
  // A list of SAP validation metrics data.
  repeated ValidationDetail validation_details = 1;

  // The project_id of the cloud project that the Insight data comes from.
  string project_id = 2;

  // The zone of the instance that the Insight data comes from.
  string zone = 3;
}

// The schema of torso workload validation data.
message TorsoValidation {
  // WorkloadType enumerates the types of supported torso workloads.
  enum WorkloadType {
    WORKLOAD_TYPE_UNSPECIFIED = 0;
    MYSQL = 1;
    ORACLE = 2;
    REDIS = 3;
  }

  // workload_type specifies the type of torso workload.
  WorkloadType workload_type = 1;

  // validation_details contains the <k,v> pairs of validation data:
  // field name & field value.
  map<string, string> validation_details = 2;

  // agent_version lists the version of the agent that collected this data.
  string agent_version = 3;

  // project_id lists the human readable cloud project that the data comes from.
  string project_id = 4;

  // instance_name lists the human readable name of the instance that the data
  // comes from.
  // (-- api-linter: core::0122::name-suffix=disabled
  //     aip.dev/not-precedent: Disambiguation between instance_id and
  //     instance_name. --)
  string instance_name = 5;
}

// The schema of openshift workload validation data.
message OpenShiftValidation {
  // The OpenShift cluster ID (e.g. 8371bb05-ab12-ab12-ab12-0f58c4f6f936).
  string cluster_id = 1;
  // The validation details of the Openshift cluster in JSON format.
  google.protobuf.Struct validation_details = 2;
}

