Coverage for fio_wrapper/endpoints/endpoints_v1/recipe.py: 100%
11 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-16 11:50 +0100
1"""Access recipe information from FIO.
2"""
3from typing import Optional
4from fio_wrapper.endpoints.abstracts.abstract_endpoint import AbstractEndpoint
5from fio_wrapper.endpoints.abstracts.abstract_recipe import AbstractRecipe
6from fio_wrapper.models.recipe_models import MaterialRecipeList, RecipeList
9class Recipe(AbstractRecipe, AbstractEndpoint):
10 # /recipes/{Ticker}
11 def get(
12 self, material_ticker: str, timeout: Optional[float] = None
13 ) -> MaterialRecipeList:
14 """Gets all recipes for given material from FIO
16 Args:
17 material_ticker (str): Material Ticker (e.g. "FE")
18 timeout (float, optional): Request timeout in seconds. Defaults to None.
20 Returns:
21 MaterialRecipeList: List of Recipes as List[MaterialRecipeList]
22 """
23 (_, data) = self.adapter.get(
24 endpoint=self.urls.recipe_get_url(material_ticker=material_ticker),
25 timeout=timeout,
26 )
28 return MaterialRecipeList.model_validate(data)
30 # /recipes/allrecipes
31 def all(self, timeout: Optional[float] = None) -> RecipeList:
32 """Gets all recipes from FIO
34 Args:
35 timeout (float, optional): Request timeout in seconds. Defaults to None.
37 Returns:
38 RecipeList: List of Recipes as List[RecipeList]
39 """
40 (_, data) = self.adapter.get(
41 endpoint=self.urls.recipe_get_all_url(), timeout=timeout
42 )
44 return RecipeList.model_validate(data)