// Copyright 2026 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
//
//     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 google.cloud.apptopology.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/struct.proto";

option csharp_namespace = "Google.Cloud.AppTopology.V1";
option go_package = "cloud.google.com/go/apptopology/apiv1/apptopologypb;apptopologypb";
option java_multiple_files = true;
option java_outer_classname = "GraphProto";
option java_package = "com.google.cloud.apptopology.v1";
option php_namespace = "Google\\Cloud\\AppTopology\\V1";
option ruby_package = "Google::Cloud::AppTopology::V1";

// Represents a graph structure composed of nodes and edges.
message Graph {
  // A collection of unique nodes that make up the graph.
  repeated Node nodes = 1;

  // Collection of unique edges connecting the `nodes` in the graph. Both source
  // and destination nodes for each edges will be present in the `nodes` list.
  repeated Edge edges = 2;
}

// Represents the context of an entity (node or edge) in the graph.
message EntityContext {
  // The primary, namespaced type dictating the node naming format and supported
  // labels, and defined in the `Schema` (Schema.node_types/edge_types.name),
  // e.g., `Base/compute.googleapis.com/Instance`.
  string type = 1;
}

// Represents a single node in the graph.
message Node {
  // Properties associated with the node.
  // Refer to https://apptopology.googleapis.com/v1/GetSchema for a detailed
  // list of node properties.
  google.protobuf.Struct properties = 3;

  // The global unique name of the node.
  // For standard Google Cloud Platform resources, this MUST be the canonical
  // Full Resource Name.
  //
  // Examples:
  //
  // - type: compute.googleapis.com/Instance
  //   name:
  //   "//compute.googleapis.com/projects/my-project-id/zones/us-central1-a/instances/my-vm-1"
  //
  // - type: container.googleapis.com/Cluster
  //   name:
  //   "//container.googleapis.com/projects/my-project-id/locations/us-central1/clusters/my-cluster"
  string name = 4;

  // Labels attached to the node. Composable, namespaced building blocks that
  // define core attributes through associated properties. Multiple labels
  // aggregate to fully specify the functional traits and property schema of the
  // node type.
  repeated string labels = 5;

  // The context of the node.
  EntityContext context = 6;
}

// Represents a single edge connecting two nodes in the graph.
message Edge {
  // Properties associated with the edge.
  // Refer to https://apptopology.googleapis.com/v1/GetSchema for a detailed
  // list of edge properties.
  google.protobuf.Struct properties = 5;

  // The name of the source node for this edge. This is the `name` field in the
  // Node.
  string source_node_name = 6;

  // The name of the destination node for this edge. This is the `name` field in
  // the Node.
  string destination_node_name = 7;

  // Labels attached to the edge. Composable, namespaced building blocks that
  // define core attributes through associated properties. Multiple labels
  // aggregate to fully specify the functional traits and property schema of the
  // edge type.
  repeated string labels = 8;

  // The context of the edge.
  EntityContext context = 9;
}
