Add support for recipe lookup from the API
This commit is contained in:
parent
c9e6ca1681
commit
54143cd7e7
@ -148,6 +148,7 @@ sub _build_tags_response {
|
|||||||
$self -> log("api:tags", "Fetching tags - term = ".($term // "not set"));
|
$self -> log("api:tags", "Fetching tags - term = ".($term // "not set"));
|
||||||
|
|
||||||
return { results => $self -> {"system"} -> {"entities"} -> {"tags"} -> find(term => $term,
|
return { results => $self -> {"system"} -> {"entities"} -> {"tags"} -> find(term => $term,
|
||||||
|
id => "name",
|
||||||
as => "text") };
|
as => "text") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +156,35 @@ sub _build_tags_response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## @method private $ _build_recipes_response()
|
||||||
|
# Fetch the list of recipes in the system, filtered by name.
|
||||||
|
#
|
||||||
|
# @api GET /recipes
|
||||||
|
#
|
||||||
|
# @return A reference to a hash containing the API response data.
|
||||||
|
sub _build_recipes_response {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
if($self -> {"cgi"} -> request_method() eq "GET") {
|
||||||
|
my ($name, $error) = $self -> validate_string("name", { required => 1,
|
||||||
|
default => undef,
|
||||||
|
nicename => "name" });
|
||||||
|
$self -> api_errorhash("bad_request",
|
||||||
|
$self -> {"template"} -> replace_langvar("API_BAD_REQUEST_DATA",
|
||||||
|
{
|
||||||
|
"%(reason)s" => $error
|
||||||
|
}))
|
||||||
|
if($error);
|
||||||
|
|
||||||
|
$self -> log("api:recipes", "Fetching recipe - name = ".($name // "not set"));
|
||||||
|
|
||||||
|
return { results => $self -> {"system"} -> {"recipe"} -> find(name => $name) };
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self -> api_errorhash("bad_request", $self -> {"template"} -> replace_langvar("API_BAD_REQUEST"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Interface functions
|
# Interface functions
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user