Skip to main content

openstack_keystone_core/catalog/
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;
16
17use crate::catalog::error::CatalogProviderError;
18use crate::catalog::types::{Endpoint, EndpointListParameters, Service, ServiceListParameters};
19use crate::keystone::ServiceState;
20
21#[cfg_attr(test, mockall::automock)]
22#[async_trait]
23pub trait CatalogBackend: Send + Sync {
24    /// List services
25    async fn list_services(
26        &self,
27        state: &ServiceState,
28        params: &ServiceListParameters,
29    ) -> Result<Vec<Service>, CatalogProviderError>;
30
31    /// Get single service by ID
32    async fn get_service<'a>(
33        &self,
34        state: &ServiceState,
35        id: &'a str,
36    ) -> Result<Option<Service>, CatalogProviderError>;
37
38    /// List Endpoints
39    async fn list_endpoints(
40        &self,
41        state: &ServiceState,
42        params: &EndpointListParameters,
43    ) -> Result<Vec<Endpoint>, CatalogProviderError>;
44
45    /// Get single endpoint by ID
46    async fn get_endpoint<'a>(
47        &self,
48        state: &ServiceState,
49        id: &'a str,
50    ) -> Result<Option<Endpoint>, CatalogProviderError>;
51
52    /// Get Catalog (Services with Endpoints)
53    async fn get_catalog(
54        &self,
55        state: &ServiceState,
56        enabled: bool,
57    ) -> Result<Vec<(Service, Vec<Endpoint>)>, CatalogProviderError>;
58}