-- | Access the @/users@ endpoint.
--
-- Example:
--
-- @
-- >>> import Web.Pagure
-- >>> let pc = PagureConfig "https://pagure.io" Nothing
-- >>> runPagureT users pc
-- ["adamwill","alphacc","asamalik","ausil","bkabrda","bochecha",[...]
-- @
users ::
  Maybe T.Text -- ^ Optional pattern to search for
  -> PagureT [Username]
users pattern = do
  opts <- pagureWreqOptions
  let opts' = case pattern of
        Nothing -> opts
        Just p -> opts & param "pattern" .~ [p]
  resp <- pagureGetWith opts' "users"
  return $ resp ^.. responseBody . key "users" . values . _String

-- | Access the @/groups@ endpoint.
--
-- Example:
--
-- @
-- >>> import Web.Pagure
-- >>> let pc = PagureConfig "https://pagure.io" Nothing
-- >>> runPagureT groups pc
-- ["releng","Fedora-Infra"]
-- @
users ::
  Maybe T.Text -- ^ Optional pattern to search for
  -> PagureT [Username]
users pattern = do
  opts <- pagureWreqOptions
  let opts' = case pattern of
        Nothing -> opts
        Just p -> opts & param "pattern" .~ [p]
  resp <- pagureGetWith opts' "users"
  return $ resp ^.. responseBody . key "users" . values . _String

-- | Access the @/groups@ endpoint.
--
-- Example:
--
-- @
-- >>> import Web.Pagure
-- >>> let pc = PagureConfig "https://pagure.io" Nothing
-- >>> runPagureT groups pc
-- ["releng","Fedora-Infra"]
-- @
users pattern = do
  opts <- pagureWreqOptions
  let opts' = case pattern of
        Nothing -> opts
        Just p -> opts & param "pattern" .~ [p]
  resp <- pagureGetWith opts' "users"
  return $ resp ^.. responseBody . key "users" . values . _String

-- | Access the @/groups@ endpoint.
--
-- Example:
--
-- @
-- >>> import Web.Pagure
-- >>> let pc = PagureConfig "https://pagure.io" Nothing
-- >>> runPagureT groups pc
-- ["releng","Fedora-Infra"]
-- @