/*
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.status;

option go_package = "github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos/status";
option java_multiple_files = true;
option java_package = "com.google.cloud.workloadagentplatform.sharedprotos.status";

message AgentStatus {
  string installed_version = 1;
  string available_version = 2;
  State systemd_service_enabled = 3;
  State systemd_service_running = 4;
  string configuration_file_path = 5;
  State configuration_valid = 6;
  string configuration_error_message = 7;
  repeated ServiceStatus services = 8;
  repeated Reference references = 9;
  string agent_name = 10;
  State cloud_api_access_full_scopes_granted = 11;
  KernelVersion kernel_version = 12;
  string instance_uri =
      13;  // Format: projects/<project>/zones/<zone>/instances/<instance>
}

message ServiceStatus {
  string name = 1;
  State state = 2;
  State fully_functional = 3;
  string error_message = 4;
  repeated IAMPermission iam_permissions = 5;
  repeated ConfigValue config_values = 6;
  string unspecified_state_message = 7;
}

message IAMPermission {
  string name = 1;
  State granted = 3;
}

message ConfigValue {
  string name = 1;
  string value = 2;
  bool is_default = 3;
}

message Reference {
  string name = 1;
  string url = 2;
}

enum State {
  UNSPECIFIED_STATE = 0;
  SUCCESS_STATE = 1;
  FAILURE_STATE = 2;
  ERROR_STATE = 3;
}

// KernelVersion encapsulates the kernel version data for the system.
message KernelVersion {
  // Version is reported as Major.Minor.Build.Patch.
  message Version {
    int32 major = 1;
    int32 minor = 2;
    int32 build = 3;
    int32 patch = 4;
    // A catch-all for any unparsed version components.
    // This is in case the number of points in the version string exceeds the
    // expected count of 4.
    string remainder = 5;
  }

  string raw_string = 1;

  // Captures the OS-specific kernel version, the portion of the string up to
  // the first dash.
  Version os_kernel = 2;

  // Captures the distro-specific kernel version, the portion of the string
  // following the first dash.
  Version distro_kernel = 3;
}
