Skip to content

Commit

Permalink
Fix get_compute_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Jul 12, 2023
1 parent 3282452 commit 7820fca
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 81 deletions.
3 changes: 2 additions & 1 deletion aiochris/link/http.py
Expand Up @@ -124,7 +124,7 @@ async def wrapped(self: Linked, *args, **kwargs) -> _R:


def search(
collection_name: str,
collection_name: str, subpath: str = "search/"
) -> Callable[[Callable[..., Search[_R]]], Callable[..., Search[_R]]]:
"""
Creates a decorator which searches the collection using GET requests.
Expand All @@ -145,6 +145,7 @@ def wrapped(self: Linked, *args, **kwargs) -> Search[_R]:
base_url=self._get_link(collection_name),
params=kwargs,
max_requests=self.max_search_requests,
subpath=subpath,
)

LinkedMeta.mark_to_check(wrapped, collection_name)
Expand Down
2 changes: 1 addition & 1 deletion aiochris/models/public.py
Expand Up @@ -43,7 +43,7 @@ class PublicPlugin(LinkedModel):
compute_resources: ComputeResourceUrl
plugin_type: PluginType = serde.field(rename="type")

@http.get("compute_resources")
@http.search("compute_resources", subpath="")
def get_compute_resources(self) -> Search[ComputeResource]:
"""Get the compute resources this plugin is registered to."""
...
3 changes: 2 additions & 1 deletion aiochris/util/search.py
Expand Up @@ -70,6 +70,7 @@ class Search(Generic[T], AsyncIterable[T]):
client: Linked
Item: Type[T]
max_requests: int = 100
subpath: str = "search/"

def __aiter__(self) -> AsyncIterator[T]:
return self._paginate(self.url)
Expand Down Expand Up @@ -168,7 +169,7 @@ def _first_url(self) -> yarl.URL:

@property
def _search_url(self) -> yarl.URL:
return yarl.URL(self.base_url) / "search/"
return yarl.URL(self.base_url) / self.subpath

def _search_url_with(self, query: dict[str, Any]):
return yarl.URL(self._search_url).with_query(query)
Expand Down

0 comments on commit 7820fca

Please sign in to comment.