// 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
//
//     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.apiregistry.v1beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/apiregistry/v1beta/resources.proto";

option csharp_namespace = "Google.Cloud.ApiRegistry.V1Beta";
option go_package = "cloud.google.com/go/apiregistry/apiv1beta/apiregistrypb;apiregistrypb";
option java_multiple_files = true;
option java_outer_classname = "ServiceProto";
option java_package = "com.google.cloud.apiregistry.v1beta";
option php_namespace = "Google\\Cloud\\ApiRegistry\\V1beta";
option ruby_package = "Google::Cloud::ApiRegistry::V1beta";
option (google.api.resource_definition) = {
  type: "cloudapiregistry.googleapis.com/ApiNamespace"
  pattern: "projects/{project}/locations/{location}/apiNamespaces/{api_namespace}"
};

// The Cloud API Registry service provides a central registry for managing API
// Data.
service CloudApiRegistry {
  option (google.api.default_host) = "cloudapiregistry.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Gets a single McpServer.
  rpc GetMcpServer(GetMcpServerRequest) returns (McpServer) {
    option (google.api.http) = {
      get: "/v1beta/{name=projects/*/locations/*/mcpServers/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists McpServers in a given Project.
  rpc ListMcpServers(ListMcpServersRequest) returns (ListMcpServersResponse) {
    option (google.api.http) = {
      get: "/v1beta/{parent=projects/*/locations/*}/mcpServers"
    };
    option (google.api.method_signature) = "parent";
  }

  // Gets a single McpTool.
  rpc GetMcpTool(GetMcpToolRequest) returns (McpTool) {
    option (google.api.http) = {
      get: "/v1beta/{name=projects/*/locations/*/mcpServers/*/mcpTools/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists McpTools in a given McpServer.
  rpc ListMcpTools(ListMcpToolsRequest) returns (ListMcpToolsResponse) {
    option (google.api.http) = {
      get: "/v1beta/{parent=projects/*/locations/*/mcpServers/*}/mcpTools"
    };
    option (google.api.method_signature) = "parent";
  }
}

// Message for getting a McpServer
message GetMcpServerRequest {
  // Required. Name of the resource
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudapiregistry.googleapis.com/McpServer"
    }
  ];
}

// Message for requesting list of McpServers
message ListMcpServersRequest {
  // Required. Parent value for ListMcpServersRequest
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "locations.googleapis.com/Location"
    }
  ];

  // Optional. Requested page size. Server may return fewer items than
  // requested. If unspecified, server will pick an appropriate default.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A token identifying a page of results the server should return.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Filtering results
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Hint for how to order the results
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Message for response to listing McpServers
message ListMcpServersResponse {
  // The list of McpServer
  repeated McpServer mcp_servers = 1;

  // A token identifying a page of results the server should return.
  string next_page_token = 2;

  // Locations that could not be reached.
  repeated string unreachable = 3;
}

// Message for getting a McpTool
message GetMcpToolRequest {
  // Required. Name of the resource
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudapiregistry.googleapis.com/McpTool"
    }
  ];
}

// Message for requesting list of McpTools
message ListMcpToolsRequest {
  // Required. Parent value for ListMcpToolsRequest
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "cloudapiregistry.googleapis.com/McpTool"
    }
  ];

  // Optional. Requested page size. Server may return fewer items than
  // requested. If unspecified, server will pick an appropriate default.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A token identifying a page of results the server should return.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Filtering results
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Hint for how to order the results
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Message for response to listing McpTools
message ListMcpToolsResponse {
  // The list of McpTool
  repeated McpTool mcp_tools = 1;

  // A token identifying a page of results the server should return.
  string next_page_token = 2;

  // Locations that could not be reached.
  repeated string unreachable = 3;
}
