[pve-devel] [PATCH v3 proxmox 06/66] notify: api: add API for sendmail endpoints
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Jul 19 14:09:17 CEST 2023
On Wed, Jul 19, 2023 at 01:51:33PM +0200, Lukas Wagner wrote:
>
>
> 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>
Fair enough.
More information about the pve-devel
mailing list