Skip to main content

openstack_keystone_core/k8s_auth/
backend.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//! # K8s auth: Backends.
15use async_trait::async_trait;
16
17use crate::k8s_auth::{K8sAuthProviderError, types::*};
18use crate::keystone::ServiceState;
19
20/// K8s auth Backend trait.
21///
22/// Backend driver interface expected by the revocation auth_instance.
23#[cfg_attr(test, mockall::automock)]
24#[async_trait]
25pub trait K8sAuthBackend: Send + Sync {
26    /// Register new K8s auth auth_instance.
27    async fn create_auth_instance(
28        &self,
29        state: &ServiceState,
30        auth_instance: K8sAuthInstanceCreate,
31    ) -> Result<K8sAuthInstance, K8sAuthProviderError>;
32
33    /// Register new K8s auth role.
34    async fn create_auth_role(
35        &self,
36        state: &ServiceState,
37        role: K8sAuthRoleCreate,
38    ) -> Result<K8sAuthRole, K8sAuthProviderError>;
39
40    /// Delete K8s auth auth_instance.
41    async fn delete_auth_instance<'a>(
42        &self,
43        state: &ServiceState,
44        id: &'a str,
45    ) -> Result<(), K8sAuthProviderError>;
46
47    /// Delete K8s auth role.
48    async fn delete_auth_role<'a>(
49        &self,
50        state: &ServiceState,
51        id: &'a str,
52    ) -> Result<(), K8sAuthProviderError>;
53
54    /// Register new K8s auth auth_instance.
55    async fn get_auth_instance<'a>(
56        &self,
57        state: &ServiceState,
58        id: &'a str,
59    ) -> Result<Option<K8sAuthInstance>, K8sAuthProviderError>;
60
61    /// Register new K8s auth role.
62    async fn get_auth_role<'a>(
63        &self,
64        state: &ServiceState,
65        id: &'a str,
66    ) -> Result<Option<K8sAuthRole>, K8sAuthProviderError>;
67
68    /// List K8s auth auth_instances.
69    async fn list_auth_instances(
70        &self,
71        state: &ServiceState,
72        params: &K8sAuthInstanceListParameters,
73    ) -> Result<Vec<K8sAuthInstance>, K8sAuthProviderError>;
74
75    /// List K8s auth roles.
76    async fn list_auth_roles(
77        &self,
78        state: &ServiceState,
79        params: &K8sAuthRoleListParameters,
80    ) -> Result<Vec<K8sAuthRole>, K8sAuthProviderError>;
81
82    /// Update K8s auth auth_instance.
83    async fn update_auth_instance<'a>(
84        &self,
85        state: &ServiceState,
86        id: &'a str,
87        data: K8sAuthInstanceUpdate,
88    ) -> Result<K8sAuthInstance, K8sAuthProviderError>;
89
90    /// Update K8s auth role.
91    async fn update_auth_role<'a>(
92        &self,
93        state: &ServiceState,
94        id: &'a str,
95        data: K8sAuthRoleUpdate,
96    ) -> Result<K8sAuthRole, K8sAuthProviderError>;
97}