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

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/discoveryengine/v1/engine.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1";
option go_package = "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "EngineServiceProto";
option java_package = "com.google.cloud.discoveryengine.v1";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1";

// Service for managing [Engine][google.cloud.discoveryengine.v1.Engine]
// configuration.
service EngineService {
  option (google.api.default_host) = "discoveryengine.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a [Engine][google.cloud.discoveryengine.v1.Engine].
  rpc CreateEngine(CreateEngineRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*/collections/*}/engines"
      body: "engine"
    };
    option (google.api.method_signature) = "parent,engine,engine_id";
    option (google.longrunning.operation_info) = {
      response_type: "google.cloud.discoveryengine.v1.Engine"
      metadata_type: "google.cloud.discoveryengine.v1.CreateEngineMetadata"
    };
  }

  // Deletes a [Engine][google.cloud.discoveryengine.v1.Engine].
  rpc DeleteEngine(DeleteEngineRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/collections/*/engines/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "google.cloud.discoveryengine.v1.DeleteEngineMetadata"
    };
  }

  // Updates an [Engine][google.cloud.discoveryengine.v1.Engine]
  rpc UpdateEngine(UpdateEngineRequest) returns (Engine) {
    option (google.api.http) = {
      patch: "/v1/{engine.name=projects/*/locations/*/collections/*/engines/*}"
      body: "engine"
    };
    option (google.api.method_signature) = "engine,update_mask";
  }

  // Gets a [Engine][google.cloud.discoveryengine.v1.Engine].
  rpc GetEngine(GetEngineRequest) returns (Engine) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/collections/*/engines/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists all the [Engine][google.cloud.discoveryengine.v1.Engine]s associated
  // with the project.
  rpc ListEngines(ListEnginesRequest) returns (ListEnginesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/collections/*}/engines"
    };
    option (google.api.method_signature) = "parent";
  }
}

// Request for
// [EngineService.CreateEngine][google.cloud.discoveryengine.v1.EngineService.CreateEngine]
// method.
message CreateEngineRequest {
  // Required. The parent resource name, such as
  // `projects/{project}/locations/{location}/collections/{collection}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Collection"
    }
  ];

  // Required. The [Engine][google.cloud.discoveryengine.v1.Engine] to create.
  Engine engine = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The ID to use for the
  // [Engine][google.cloud.discoveryengine.v1.Engine], which will become the
  // final component of the [Engine][google.cloud.discoveryengine.v1.Engine]'s
  // resource name.
  //
  // This field must conform to [RFC-1034](https://tools.ietf.org/html/rfc1034)
  // standard with a length limit of 63 characters. Otherwise, an
  // INVALID_ARGUMENT error is returned.
  string engine_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// Metadata related to the progress of the
// [EngineService.CreateEngine][google.cloud.discoveryengine.v1.EngineService.CreateEngine]
// operation. This will be returned by the google.longrunning.Operation.metadata
// field.
message CreateEngineMetadata {
  // Operation create time.
  google.protobuf.Timestamp create_time = 1;

  // Operation last update time. If the operation is done, this is also the
  // finish time.
  google.protobuf.Timestamp update_time = 2;
}

// Request message for
// [EngineService.DeleteEngine][google.cloud.discoveryengine.v1.EngineService.DeleteEngine]
// method.
message DeleteEngineRequest {
  // Required. Full resource name of
  // [Engine][google.cloud.discoveryengine.v1.Engine], such as
  // `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`.
  //
  // If the caller does not have permission to delete the
  // [Engine][google.cloud.discoveryengine.v1.Engine], regardless of whether or
  // not it exists, a PERMISSION_DENIED error is returned.
  //
  // If the [Engine][google.cloud.discoveryengine.v1.Engine] to delete does not
  // exist, a NOT_FOUND error is returned.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Engine"
    }
  ];
}

// Metadata related to the progress of the
// [EngineService.DeleteEngine][google.cloud.discoveryengine.v1.EngineService.DeleteEngine]
// operation. This will be returned by the google.longrunning.Operation.metadata
// field.
message DeleteEngineMetadata {
  // Operation create time.
  google.protobuf.Timestamp create_time = 1;

  // Operation last update time. If the operation is done, this is also the
  // finish time.
  google.protobuf.Timestamp update_time = 2;
}

// Request message for
// [EngineService.GetEngine][google.cloud.discoveryengine.v1.EngineService.GetEngine]
// method.
message GetEngineRequest {
  // Required. Full resource name of
  // [Engine][google.cloud.discoveryengine.v1.Engine], such as
  // `projects/{project}/locations/{location}/collections/{collection_id}/engines/{engine_id}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Engine"
    }
  ];
}

// Request message for
// [EngineService.ListEngines][google.cloud.discoveryengine.v1.EngineService.ListEngines]
// method.
message ListEnginesRequest {
  // Required. The parent resource name, such as
  // `projects/{project}/locations/{location}/collections/{collection_id}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Collection"
    }
  ];

  // Optional. Not supported.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Not supported.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Filter by solution type. For example:
  // solution_type=SOLUTION_TYPE_SEARCH
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [EngineService.ListEngines][google.cloud.discoveryengine.v1.EngineService.ListEngines]
// method.
message ListEnginesResponse {
  // All the customer's [Engine][google.cloud.discoveryengine.v1.Engine]s.
  repeated Engine engines = 1;

  // Not supported.
  string next_page_token = 2;
}

// Request message for
// [EngineService.UpdateEngine][google.cloud.discoveryengine.v1.EngineService.UpdateEngine]
// method.
message UpdateEngineRequest {
  // Required. The [Engine][google.cloud.discoveryengine.v1.Engine] to update.
  //
  // If the caller does not have permission to update the
  // [Engine][google.cloud.discoveryengine.v1.Engine], regardless of whether or
  // not it exists, a PERMISSION_DENIED error is returned.
  //
  // If the [Engine][google.cloud.discoveryengine.v1.Engine] to update does not
  // exist, a NOT_FOUND error is returned.
  Engine engine = 1 [(google.api.field_behavior) = REQUIRED];

  // Indicates which fields in the provided
  // [Engine][google.cloud.discoveryengine.v1.Engine] to update.
  //
  // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
  // is returned.
  google.protobuf.FieldMask update_mask = 2;
}
