From 718ec10aafd46d421449702783efd04e0c2df029 Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Aug 30 2015 18:05:30 +0000 Subject: Make "tags" take an optional pattern Signed-off-by: Ricky Elrod --- diff --git a/src/Web/Pagure/Extras.hs b/src/Web/Pagure/Extras.hs index f45f081..76882ab 100644 --- a/src/Web/Pagure/Extras.hs +++ b/src/Web/Pagure/Extras.hs @@ -38,17 +38,27 @@ version = do -- | Access the @/[repo]/tags@ endpoint. -- +-- Takes an optional @pattern@ that (according to the API documentation) +-- "filters the starting letters of the tags." +-- -- Example: -- -- @ -- >>> import Web.Pagure -- >>> let pc = PagureConfig "https://pagure.io" Nothing --- >>> runPagureT (tags "pagure") pc +-- >>> runPagureT (tags "pagure" Nothing) pc -- ["0.1","0.2","Artwork","doc","easyfix","email","wishful"] -- @ -tags :: Repo -> PagureT [Tag] -tags r = do - resp <- pagureGet (r ++ "/tags") +tags :: + Repo + -> Maybe T.Text -- ^ An optional @pattern@. + -> PagureT [Tag] +tags r pattern = do + opts <- pagureWreqOptions + let opts' = case pattern of + Just p -> opts & param "pattern" .~ [p] + Nothing -> opts + resp <- pagureGetWith opts' (r ++ "/tags") return $ resp ^.. responseBody . key "tags" . values . _String -- | Access the @/error_codes@ endpoint.