// 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.alloydb.v1alpha;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/alloydb/v1alpha/csql_resources.proto";
import "google/cloud/alloydb/v1alpha/resources.proto";
import "google/cloud/alloydb/v1alpha/service.proto";
import "google/longrunning/operations.proto";

option csharp_namespace = "Google.Cloud.AlloyDb.V1Alpha";
option go_package = "cloud.google.com/go/alloydb/apiv1alpha/alloydbpb;alloydbpb";
option java_multiple_files = true;
option java_outer_classname = "CSQLServiceProto";
option java_package = "com.google.cloud.alloydb.v1alpha";
option php_namespace = "Google\\Cloud\\AlloyDb\\V1alpha";
option ruby_package = "Google::Cloud::AlloyDB::V1alpha";

// Service for interactions with CloudSQL.
service AlloyDBCSQLAdmin {
  option (google.api.default_host) = "alloydb.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Restores an AlloyDB cluster from a CloudSQL resource.
  rpc RestoreFromCloudSQL(RestoreFromCloudSQLRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1alpha/{parent=projects/*/locations/*}/clusters:restoreFromCloudSQL"
      body: "*"
    };
    option (google.api.method_signature) = "parent,cluster_id";
    option (google.longrunning.operation_info) = {
      response_type: "Cluster"
      metadata_type: "OperationMetadata"
    };
  }
}

// Message for registering Restoring from CloudSQL resource.
message RestoreFromCloudSQLRequest {
  // The source CloudSQL resource to restore from.
  oneof source {
    // Cluster created from CloudSQL backup run.
    CloudSQLBackupRunSource cloudsql_backup_run_source = 101;
  }

  // Required. The location of the new cluster. For the required format, see the
  // comment on Cluster.name field.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "alloydb.googleapis.com/Cluster"
    }
  ];

  // Required. ID of the requesting object.
  string cluster_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The resource being created
  Cluster cluster = 3 [(google.api.field_behavior) = REQUIRED];
}
