Skip to main content

openstack_keystone_core/role/
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
15use async_trait::async_trait;
16use std::collections::{BTreeMap, BTreeSet};
17
18use crate::keystone::ServiceState;
19use crate::role::{RoleProviderError, types::role::*};
20
21#[cfg_attr(test, mockall::automock)]
22#[async_trait]
23pub trait RoleBackend: Send + Sync {
24    /// Create Role.
25    async fn create_role(
26        &self,
27        state: &ServiceState,
28        params: RoleCreate,
29    ) -> Result<Role, RoleProviderError>;
30
31    /// Delete a role by the ID.
32    async fn delete_role<'a>(
33        &self,
34        state: &ServiceState,
35        id: &'a str,
36    ) -> Result<(), RoleProviderError>;
37
38    /// Get single role by ID
39    async fn get_role<'a>(
40        &self,
41        state: &ServiceState,
42        id: &'a str,
43    ) -> Result<Option<Role>, RoleProviderError>;
44
45    /// Expand implied roles.
46    async fn expand_implied_roles(
47        &self,
48        state: &ServiceState,
49        roles: &mut Vec<RoleRef>,
50    ) -> Result<(), RoleProviderError>;
51
52    /// List role imply rules.
53    async fn list_imply_rules(
54        &self,
55        state: &ServiceState,
56        resolve: bool,
57    ) -> Result<BTreeMap<String, BTreeSet<String>>, RoleProviderError>;
58
59    /// List Roles.
60    async fn list_roles(
61        &self,
62        state: &ServiceState,
63        params: &RoleListParameters,
64    ) -> Result<Vec<Role>, RoleProviderError>;
65}