endhost_api_discovery_models/model.rs
1// Copyright 2026 Anapaya Systems
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//! Models for Endhost API discovery.
16
17use std::net::IpAddr;
18
19use url::Url;
20
21/// RPC paths for the Endhost API Discovery service.
22pub struct RpcEndhostApiDiscoveryService;
23impl RpcEndhostApiDiscoveryService {
24 /// Service path for the Endhost API Discovery service.
25 pub const SERVICE_PATH: &'static str = "/endhost.discovery.v1.EndhostApiDiscoveryService";
26 /// RPC path for the GetEndhostApis method.
27 pub const GET_ENDHOST_APIS_PATH: &'static str = "/GetEndhostApis";
28}
29
30/// Allows discovery of available Endhost APIs.
31
32#[async_trait::async_trait]
33pub trait EndhostApiDiscovery: Send + Sync {
34 /// Discover available Endhost APIs
35 ///
36 /// Returns a list of EndhostApiInfos representing the discovered Endhost APIs.
37 /// This list is ordered by preference, with the most preferred API first.
38 ///
39 /// # Parameters
40 /// - `public_ip`: The public IP address of the endhost making the discovery request.
41 async fn discover_endhost_api(&self, public_ip: IpAddr) -> Vec<EndhostApiInfo>;
42}
43
44/// Information about an Endhost API.
45#[derive(Clone, PartialEq, Eq, Hash)]
46pub struct EndhostApiInfo {
47 /// URL of the Endhost API.
48 pub address: Url,
49}