[pve-devel] [PATCH v3 proxmox 06/66] notify: api: add API for sendmail endpoints

Lukas Wagner l.wagner at proxmox.com
Wed Jul 19 13:51:33 CEST 2023

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

More information about the pve-devel mailing list