// 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";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/longrunning/operations.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

package google.test.naming;

option java_package = "com.google.test.callablenamingtype";
option java_multiple_files = true;

// This service exercises two scenarios where the RPC name previously would attempt
// to generate the incorrect type of RPC:
// 1. Unary RPCs that ended with `Operation` would be assumed to be an LRO
// 2. Unary (non-paged) RPCs that ended `Paged` would be assumed to be Paged
service CallableNameTypeService {

  option (google.api.default_host) = "localhost:7469";

  // The generator should not parse this RPC as an LRO and should not generate
  // an operation callable for this
  rpc GetApiOperation(GetApiOperationRequest) returns (ApiOperation) {
    option (google.api.http) = {
      get: "/v1/{name=apiOperations/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // The generator should not parse this as a Paged callable and should not
  // generate a paged callable for this
  rpc ApiPaged(GetApiOperationRequest) returns (ApiOperation) {
    option (google.api.http) = {
      get: "/v1/{name=apiOperations/*}"
    };
    option (google.api.method_signature) = "name";
  }
}

message GetApiOperationRequest {
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "testing.com/ApiOperation"
    }
  ];
}

message ApiOperation {
  option (google.api.resource) = {
    type: "testing.com/ApiOperation"
    pattern: "apiOperations/{operation}"
    plural: "apiOperations"
    singular: "apiOperation"
  };

  string name = 1;
}


