Skip to main content

fluss/rpc/message/
drop_partition.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use crate::metadata::{PartitionSpec, TablePath};
19use crate::proto::DropPartitionResponse;
20use crate::rpc::api_key::ApiKey;
21use crate::rpc::api_version::ApiVersion;
22use crate::rpc::convert::to_table_path;
23use crate::rpc::frame::{ReadError, WriteError};
24use crate::rpc::message::{ReadVersionedType, RequestBody, WriteVersionedType};
25use crate::{impl_read_version_type, impl_write_version_type, proto};
26use bytes::{Buf, BufMut};
27use prost::Message;
28
29#[derive(Debug)]
30pub struct DropPartitionRequest {
31    pub inner_request: proto::DropPartitionRequest,
32}
33
34impl DropPartitionRequest {
35    pub fn new(
36        table_path: &TablePath,
37        partition_spec: &PartitionSpec,
38        ignore_if_not_exists: bool,
39    ) -> Self {
40        DropPartitionRequest {
41            inner_request: proto::DropPartitionRequest {
42                table_path: to_table_path(table_path),
43                partition_spec: partition_spec.to_pb(),
44                ignore_if_not_exists,
45            },
46        }
47    }
48}
49
50impl RequestBody for DropPartitionRequest {
51    type ResponseBody = DropPartitionResponse;
52
53    const API_KEY: ApiKey = ApiKey::DropPartition;
54
55    const REQUEST_VERSION: ApiVersion = ApiVersion(0);
56}
57
58impl_write_version_type!(DropPartitionRequest);
59impl_read_version_type!(DropPartitionResponse);