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

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/field_info.proto";
import "google/api/resource.proto";
import "google/cloud/managedkafka/v1/resources.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.ManagedKafka.V1";
option go_package = "cloud.google.com/go/managedkafka/apiv1/managedkafkapb;managedkafkapb";
option java_multiple_files = true;
option java_outer_classname = "ManagedKafkaConnectProto";
option java_package = "com.google.cloud.managedkafka.v1";
option php_namespace = "Google\\Cloud\\ManagedKafka\\V1";
option ruby_package = "Google::Cloud::ManagedKafka::V1";

// The service that a client application uses to manage Apache Kafka Connect
// clusters and connectors.
service ManagedKafkaConnect {
  option (google.api.default_host) = "managedkafka.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Lists the Kafka Connect clusters in a given project and location.
  rpc ListConnectClusters(ListConnectClustersRequest)
      returns (ListConnectClustersResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/connectClusters"
    };
    option (google.api.method_signature) = "parent";
  }

  // Returns the properties of a single Kafka Connect cluster.
  rpc GetConnectCluster(GetConnectClusterRequest) returns (ConnectCluster) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/connectClusters/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new Kafka Connect cluster in a given project and location.
  rpc CreateConnectCluster(CreateConnectClusterRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/connectClusters"
      body: "connect_cluster"
    };
    option (google.api.method_signature) =
        "parent,connect_cluster,connect_cluster_id";
    option (google.longrunning.operation_info) = {
      response_type: "ConnectCluster"
      metadata_type: "OperationMetadata"
    };
  }

  // Updates the properties of a single Kafka Connect cluster.
  rpc UpdateConnectCluster(UpdateConnectClusterRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v1/{connect_cluster.name=projects/*/locations/*/connectClusters/*}"
      body: "connect_cluster"
    };
    option (google.api.method_signature) = "connect_cluster,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "ConnectCluster"
      metadata_type: "OperationMetadata"
    };
  }

  // Deletes a single Connect cluster.
  rpc DeleteConnectCluster(DeleteConnectClusterRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/connectClusters/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "OperationMetadata"
    };
  }

  // Lists the connectors in a given Connect cluster.
  rpc ListConnectors(ListConnectorsRequest) returns (ListConnectorsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/connectClusters/*}/connectors"
    };
    option (google.api.method_signature) = "parent";
  }

  // Returns the properties of a single connector.
  rpc GetConnector(GetConnectorRequest) returns (Connector) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new connector in a given Connect cluster.
  rpc CreateConnector(CreateConnectorRequest) returns (Connector) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*/connectClusters/*}/connectors"
      body: "connector"
    };
    option (google.api.method_signature) = "parent,connector,connector_id";
  }

  // Updates the properties of a connector.
  rpc UpdateConnector(UpdateConnectorRequest) returns (Connector) {
    option (google.api.http) = {
      patch: "/v1/{connector.name=projects/*/locations/*/connectClusters/*/connectors/*}"
      body: "connector"
    };
    option (google.api.method_signature) = "connector,update_mask";
  }

  // Deletes a connector.
  rpc DeleteConnector(DeleteConnectorRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Pauses the connector and its tasks.
  rpc PauseConnector(PauseConnectorRequest) returns (PauseConnectorResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}:pause"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }

  // Resumes the connector and its tasks.
  rpc ResumeConnector(ResumeConnectorRequest)
      returns (ResumeConnectorResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}:resume"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }

  // Restarts the connector.
  rpc RestartConnector(RestartConnectorRequest)
      returns (RestartConnectorResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}:restart"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }

  // Stops the connector.
  rpc StopConnector(StopConnectorRequest) returns (StopConnectorResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/connectClusters/*/connectors/*}:stop"
      body: "*"
    };
    option (google.api.method_signature) = "name";
  }
}

// Request for GetConnectCluster.
message GetConnectClusterRequest {
  // Required. The name of the Kafka Connect cluster whose configuration to
  // return. Structured like
  // `projects/{project}/locations/{location}/connectClusters/{connect_cluster_id}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/ConnectCluster"
    }
  ];
}

// Request for CreateConnectCluster.
message CreateConnectClusterRequest {
  // Required. The parent project/location in which to create the Kafka Connect
  // cluster. Structured like
  // `projects/{project}/locations/{location}/`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "managedkafka.googleapis.com/ConnectCluster"
    }
  ];

  // Required. The ID to use for the Connect cluster, which will become the
  // final component of the cluster's name. The ID must be 1-63 characters long,
  // and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` to comply
  // with RFC 1035.
  //
  // This value is structured like: `my-cluster-id`.
  string connect_cluster_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Configuration of the Kafka Connect cluster to create. Its `name`
  // field is ignored.
  ConnectCluster connect_cluster = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID to avoid duplication of requests. If a request times out or
  // fails, retrying with the same ID allows the server to recognize the
  // previous attempt. For at least 60 minutes, the server ignores duplicate
  // requests bearing the same ID.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request ID
  // within 60 minutes of the last request, the server checks if an original
  // operation with the same request ID was received. If so, the server ignores
  // the second request.
  //
  // The request ID must be a valid UUID. A zero UUID is not supported
  // (00000000-0000-0000-0000-000000000000).
  string request_id = 4 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request for UpdateConnectCluster.
message UpdateConnectClusterRequest {
  // Required. Field mask is used to specify the fields to be overwritten in the
  // cluster resource by the update. The fields specified in the update_mask are
  // relative to the resource, not the full request. A field will be overwritten
  // if it is in the mask. The mask is required and a value of * will update all
  // fields.
  google.protobuf.FieldMask update_mask = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. The Kafka Connect cluster to update. Its `name` field must be
  // populated.
  ConnectCluster connect_cluster = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID to avoid duplication of requests. If a request times out or
  // fails, retrying with the same ID allows the server to recognize the
  // previous attempt. For at least 60 minutes, the server ignores duplicate
  // requests bearing the same ID.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request ID
  // within 60 minutes of the last request, the server checks if an original
  // operation with the same request ID was received. If so, the server ignores
  // the second request.
  //
  // The request ID must be a valid UUID. A zero UUID is not supported
  // (00000000-0000-0000-0000-000000000000).
  string request_id = 3 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request for DeleteConnectCluster.
message DeleteConnectClusterRequest {
  // Required. The name of the Kafka Connect cluster to delete.
  // Structured like
  // `projects/{project}/locations/{location}/connectClusters/{connect_cluster_id}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/ConnectCluster"
    }
  ];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID to avoid duplication of requests. If a request times out or
  // fails, retrying with the same ID allows the server to recognize the
  // previous attempt. For at least 60 minutes, the server ignores duplicate
  // requests bearing the same ID.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request ID
  // within 60 minutes of the last request, the server checks if an original
  // operation with the same request ID was received. If so, the server ignores
  // the second request.
  //
  // The request ID must be a valid UUID. A zero UUID is not supported
  // (00000000-0000-0000-0000-000000000000).
  string request_id = 2 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request for ListConnectClusters.
message ListConnectClustersRequest {
  // Required. The parent project/location whose Connect clusters are to be
  // listed. Structured like `projects/{project}/locations/{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "managedkafka.googleapis.com/ConnectCluster"
    }
  ];

  // Optional. The maximum number of Connect clusters to return. The service may
  // return fewer than this value. If unspecified, server will pick an
  // appropriate default.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `ListConnectClusters`
  // call. Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to `ListConnectClusters`
  // must match the call that provided the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Filter expression for the result.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Order by fields for the result.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response for ListConnectClusters.
message ListConnectClustersResponse {
  // The list of Connect clusters in the requested parent.
  repeated ConnectCluster connect_clusters = 1;

  // A token that can be sent as `page_token` to retrieve the next page of
  // results. If this field is omitted, there are no more results.
  string next_page_token = 2;

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

// Request for GetConnector.
message GetConnectorRequest {
  // Required. The name of the connector whose configuration to return.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Request for CreateConnector.
message CreateConnectorRequest {
  // Required. The parent Connect cluster in which to create the connector.
  // Structured like
  // `projects/{project}/locations/{location}/connectClusters/{connect_cluster_id}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "managedkafka.googleapis.com/Connector"
    }
  ];

  // Required. The ID to use for the connector, which will become the final
  // component of the connector's name. The ID must be 1-63 characters long, and
  // match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` to comply with
  // RFC 1035.
  //
  // This value is structured like: `my-connector-id`.
  string connector_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The connector to create.
  Connector connector = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request for UpdateConnector.
message UpdateConnectorRequest {
  // Required. Field mask is used to specify the fields to be overwritten in the
  // cluster resource by the update. The fields specified in the update_mask are
  // relative to the resource, not the full request. A field will be overwritten
  // if it is in the mask. The mask is required and a value of * will update all
  // fields.
  google.protobuf.FieldMask update_mask = 1
      [(google.api.field_behavior) = REQUIRED];

  // Required. The connector to update. Its `name` field must be populated.
  Connector connector = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request for DeleteConnector.
message DeleteConnectorRequest {
  // Required. The name of the connector to delete.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Request for ListConnectors.
message ListConnectorsRequest {
  // Required. The parent Connect cluster whose connectors are to be listed.
  // Structured like
  // `projects/{project}/locations/{location}/connectClusters/{connect_cluster_id}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "managedkafka.googleapis.com/Connector"
    }
  ];

  // Optional. The maximum number of connectors to return. The service may
  // return fewer than this value. If unspecified, server will pick an
  // appropriate default.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `ListConnectors` call.
  // Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to `ListConnectors`
  // must match the call that provided the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response for ListConnectors.
message ListConnectorsResponse {
  // The list of connectors in the requested parent.
  repeated Connector connectors = 1;

  // A token that can be sent as `page_token` to retrieve the next page of
  // results. If this field is omitted, there are no more results.
  string next_page_token = 2;
}

// Request for PauseConnector.
message PauseConnectorRequest {
  // Required. The name of the connector to pause.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Response for PauseConnector.
message PauseConnectorResponse {}

// Request for ResumeConnector.
message ResumeConnectorRequest {
  // Required. The name of the connector to pause.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Response for ResumeConnector.
message ResumeConnectorResponse {}

// Request for RestartConnector.
message RestartConnectorRequest {
  // Required. The name of the connector to restart.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Response for RestartConnector.
message RestartConnectorResponse {}

// Request for StopConnector.
message StopConnectorRequest {
  // Required. The name of the connector to stop.
  // Structured like:
  // projects/{project}/locations/{location}/connectClusters/{connectCluster}/connectors/{connector}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "managedkafka.googleapis.com/Connector"
    }
  ];
}

// Response for StopConnector.
message StopConnectorResponse {}
