// 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.agentregistry.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/agentregistry/v1/properties.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.AgentRegistry.V1";
option go_package = "cloud.google.com/go/agentregistry/apiv1/agentregistrypb;agentregistrypb";
option java_multiple_files = true;
option java_outer_classname = "ServiceProto";
option java_package = "com.google.cloud.agentregistry.v1";
option php_namespace = "Google\\Cloud\\AgentRegistry\\V1";
option ruby_package = "Google::Cloud::AgentRegistry::V1";

// Represents a user-defined Service.
message Service {
  option (google.api.resource) = {
    type: "agentregistry.googleapis.com/Service"
    pattern: "projects/{project}/locations/{location}/services/{service}"
    plural: "services"
    singular: "service"
  };

  // The spec of the agent.
  message AgentSpec {
    // The type of the agent spec.
    enum Type {
      // Unspecified type.
      TYPE_UNSPECIFIED = 0;

      // There is no spec for the Agent. The `content` field must be empty.
      NO_SPEC = 1;

      // The content is an A2A Agent Card following the A2A specification.
      // The `interfaces` field must be empty.
      A2A_AGENT_CARD = 2;
    }

    // Required. The type of the agent spec content.
    Type type = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. The content of the Agent spec in the JSON format.
    // This payload is validated against the schema for the specified type.
    // The content size is limited to `10KB`.
    google.protobuf.Struct content = 2 [(google.api.field_behavior) = OPTIONAL];
  }

  // The spec of the MCP Server.
  message McpServerSpec {
    // The type of the MCP Server spec.
    enum Type {
      // Unspecified type.
      TYPE_UNSPECIFIED = 0;

      // There is no spec for the MCP Server. The `content` field must be empty.
      NO_SPEC = 1;

      // The content is a MCP Tool Spec following the One MCP specification.
      // The payload is the same as the `tools/list` response.
      TOOL_SPEC = 2;
    }

    // Required. The type of the MCP Server spec content.
    Type type = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. The content of the MCP Server spec.
    // This payload is validated against the schema for the specified type.
    // The content size is limited to `10KB`.
    google.protobuf.Struct content = 2 [(google.api.field_behavior) = OPTIONAL];
  }

  // The spec of the endpoint.
  message EndpointSpec {
    // The type of the endpoint spec.
    enum Type {
      // Unspecified type.
      TYPE_UNSPECIFIED = 0;

      // There is no spec for the Endpoint. The `content` field must be empty.
      NO_SPEC = 1;
    }

    // Required. The type of the endpoint spec content.
    Type type = 1 [(google.api.field_behavior) = REQUIRED];

    // Optional. The content of the endpoint spec.
    // Reserved for future use.
    google.protobuf.Struct content = 2 [(google.api.field_behavior) = OPTIONAL];
  }

  // The spec of the service. At least one of the specs must be set.
  oneof spec {
    // Optional. The spec of the Agent. When `agent_spec` is set, the type of
    // the service is Agent.
    AgentSpec agent_spec = 5 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The spec of the MCP Server. When `mcp_server_spec` is set, the
    // type of the service is MCP Server.
    McpServerSpec mcp_server_spec = 6 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The spec of the Endpoint. When `endpoint_spec` is set, the type
    // of the service is Endpoint.
    EndpointSpec endpoint_spec = 7 [(google.api.field_behavior) = OPTIONAL];
  }

  // Identifier. The resource name of the Service.
  // Format: `projects/{project}/locations/{location}/services/{service}`.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. User-defined display name for the Service.
  // Can have a maximum length of `63` characters.
  string display_name = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. User-defined description of an Service.
  // Can have a maximum length of `2048` characters.
  string description = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The connection details for the Service.
  repeated Interface interfaces = 4 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The resource name of the resulting Agent, MCP Server, or
  // Endpoint. Format:
  //
  // * `projects/{project}/locations/{location}/mcpServers/{mcp_server}`
  // * `projects/{project}/locations/{location}/agents/{agent}`
  // * `projects/{project}/locations/{location}/endpoints/{endpoint}`
  string registry_resource = 10 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Create time.
  google.protobuf.Timestamp create_time = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Update time.
  google.protobuf.Timestamp update_time = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];
}
