Skip to main content

confluent_kafka/admin/
user_scram_credential_deletion.rs

1// Copyright 2025 Confluent Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! A request to delete a SASL/SCRAM credential for a user.
16
17use super::ScramMechanism;
18
19/// A request to delete a SASL/SCRAM credential for a user.
20///
21/// See [KIP-554: Add Broker-side SCRAM Config API](https://cwiki.apache.org/confluence/display/KAFKA/KIP-554%3A+Add+Broker-side+SCRAM+Config+API).
22#[derive(Debug, Clone)]
23#[doc(alias = "org.apache.kafka.clients.admin.UserScramCredentialDeletion")]
24pub struct UserScramCredentialDeletion {
25    user: String,
26    mechanism: ScramMechanism,
27}
28
29impl UserScramCredentialDeletion {
30    /// Creates a new deletion.
31    ///
32    /// # Arguments
33    ///
34    /// - `user` - the mandatory user
35    /// - `mechanism` - the mandatory mechanism
36    #[doc(alias = "org.apache.kafka.clients.admin.UserScramCredentialDeletion#UserScramCredentialDeletion")]
37    pub fn new(user: impl Into<String>, mechanism: ScramMechanism) -> Self {
38        Self { user: user.into(), mechanism }
39    }
40
41    /// Returns the always non-null user.
42    #[doc(alias = "org.apache.kafka.clients.admin.UserScramCredentialAlteration#user")]
43    pub fn user(&self) -> &str {
44        &self.user
45    }
46
47    /// Returns the always non-null mechanism.
48    #[doc(alias = "org.apache.kafka.clients.admin.UserScramCredentialDeletion#mechanism")]
49    pub fn mechanism(&self) -> ScramMechanism {
50        self.mechanism
51    }
52}
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57
58    #[test]
59    fn accessors() {
60        let deletion = UserScramCredentialDeletion::new("carol", ScramMechanism::ScramSha256);
61        assert_eq!(deletion.user(), "carol");
62        assert_eq!(deletion.mechanism(), ScramMechanism::ScramSha256);
63    }
64}