/*
Copyright 2025 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.gcbdractions;

import "google/protobuf/any.proto";

option java_multiple_files = true;
option java_package = "workloadagentplatform.sharedprotos.gcbdractions";
option go_package = "github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos/gcbdractions";

/**
 * A GCBDRActionRequest is contained in the body of an UAP message that is sent
 * to the agent by the WorkloadActions service.
 */
message GCBDRActionRequest {
  repeated Command commands = 2;
}

/**
 * A GCBDRActionResponse is contained in the body of an Agent Communication
 * message that is sent from the agent to the WorkloadActions service.
 */
message GCBDRActionResponse {
  repeated CommandResult command_results = 1;
  GCBDRActionError error = 2;
}

/**
 * Command specifies the type of command to execute.
 */
message Command {
  oneof command_type {
    AgentCommand agent_command = 1;
    ShellCommand shell_command = 2;
  }
}

/**
 * An AgentCommand specifies a one-time executable program for the agent to run.
 */
message AgentCommand {
  // command is the name of the GCBDR action that will be invoked.
  string command = 1;
  // parameters is a map of key/value pairs that can be used to specify
  // additional one-time executable settings.
  map<string, string> parameters = 2;
}

/**
 * GCBDRAction specifies the type of GCBDR action to perform.
 */
enum GCBDRAction {
  GCBDR_ACTION_UNSPECIFIED = 0;
  GCBDR_ACTION_DEEP_DISCOVERY = 1;
}

/**
 * A ShellCommand is invoked via the agent's command line executor
 */
message ShellCommand {
  // command is the name of the command to be executed.
  string command = 1;
  // args is a string of arguments to be passed to the command.
  string args = 2;
  // Optional. If not specified, the default timeout is 60 seconds.
  int32 timeout_seconds = 3;
}

/**
 * CommandResult contains the result of a single command execution.
 */
message CommandResult {
  Command command = 1;
  string stdout = 2;
  string stderr = 3;
  int32 exit_code = 4;
  google.protobuf.Any payload = 5;
}

/**
 * GCBDRActionError contains details about an error that occurred while
 * processing a GCBDRActionRequest.
 */
message GCBDRActionError {
  string error_message = 1;
}
