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

import "google/api/field_behavior.proto";
import "google/cloud/ces/v1beta/auth.proto";

option go_package = "cloud.google.com/go/ces/apiv1beta/cespb;cespb";
option java_multiple_files = true;
option java_outer_classname = "ConnectorToolProto";
option java_package = "com.google.cloud.ces.v1beta";

// Configuration of an Action for the tool to use.
// Note: This can be either an Action or an Operation. See
// https://cloud.google.com/integration-connectors/docs/entities-operation-action
// for details.
message Action {
  // Entity CRUD operation specification.
  message EntityOperation {
    // The operation to perform on the entity.
    enum OperationType {
      // Operation type unspecified. Invalid, ConnectorTool create/update
      // will fail.
      OPERATION_TYPE_UNSPECIFIED = 0;

      // List operation.
      LIST = 1;

      // Get operation.
      GET = 2;

      // Create operation.
      CREATE = 3;

      // Update operation.
      UPDATE = 4;

      // Delete operation.
      DELETE = 5;
    }

    // Required. ID of the entity.
    string entity_id = 1 [(google.api.field_behavior) = REQUIRED];

    // Required. Operation to perform on the entity.
    OperationType operation = 2 [(google.api.field_behavior) = REQUIRED];
  }

  // Specification for an action to configure for the tool to use.
  oneof action_spec {
    // ID of a Connection action for the tool to use.
    string connection_action_id = 4;

    // Entity operation configuration for the tool to use.
    EntityOperation entity_operation = 5;
  }

  // Optional. Entity fields to use as inputs for the operation.
  // If no fields are specified, all fields of the Entity will be used.
  repeated string input_fields = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Entity fields to return from the operation.
  // If no fields are specified, all fields of the Entity will be returned.
  repeated string output_fields = 3 [(google.api.field_behavior) = OPTIONAL];
}

// A ConnectorTool allows connections to different integrations.
// See: https://cloud.google.com/integration-connectors/docs/overview.
message ConnectorTool {
  // Required. The full resource name of the referenced Integration Connectors
  // Connection.
  // Format:
  // `projects/{project}/locations/{location}/connections/{connection}`
  string connection = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Action for the tool to use.
  Action action = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Configures how authentication is handled in Integration
  // Connectors. By default, an admin authentication is passed in the
  // Integration Connectors API requests. You can override it with a different
  // end-user authentication config.
  // **Note**: The Connection must have authentication override enabled in
  // order to specify an EUC configuration here - otherwise, the ConnectorTool
  // creation will fail. See
  // https://cloud.google.com/application-integration/docs/configure-connectors-task#configure-authentication-override
  // for details.
  EndUserAuthConfig auth_config = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The name of the tool that can be used by the Agent to decide
  // whether to call this ConnectorTool.
  string name = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The description of the tool that can be used by the Agent to
  // decide whether to call this ConnectorTool.
  string description = 5 [(google.api.field_behavior) = OPTIONAL];
}
