On 7/18/23 14:36, Wolfgang Bumiller wrote:
+
+/// Get sendmail endpoint with given `name`.
+///
+/// The caller is responsible for any needed permission checks.
+/// Returns the endpoint or an `ApiError` if the endpoint was not found.
+pub fn get_endpoint(config: &Config, name: &str) -> Result<SendmailConfig, 
ApiError> {
+    config
+        .config
+        .lookup(SENDMAIL_TYPENAME, name)
+        .map_err(|_| ApiError::not_found(format!("endpoint '{name}' not 
found"), None))

^ Technically `.lookup()` could have found the name but as a wrong type.
It might make sense to not use `.lookup()` in this case.


`.lookup()` should be fine here from what I can tell. I actually want a `not 
found` if there is
another endpoint with that name but a different type, because the endpoints 
have a distinct
typed path prefix in the REST API:

    GET endpoints/sendmail/<name>
    GET endpoints/gotify/<name>


--
- Lukas


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to