generated from tpl/purs
feat: setTopics
This commit is contained in:
parent
123b90c92f
commit
3fe42d78ff
@ -31,6 +31,9 @@ reposURL (Username owner) (RepoName repo) =
|
||||
repoTopicsPageURL :: forall m. Monad m => Username -> RepoName -> { page :: Int, limit :: Int } -> GiteaT m URL
|
||||
repoTopicsPageURL o repo {page, limit} = (\repos -> repos / "topics" ? "limit" /\ show limit & "page" /\ show page) <$> reposURL o repo
|
||||
|
||||
repoTopicsURL :: forall m. Monad m => Username -> RepoName -> GiteaT m URL
|
||||
repoTopicsURL o repo = (\repos -> repos / "topics") <$> reposURL o repo
|
||||
|
||||
repoTopicsOneURL :: forall m. Monad m => Username -> RepoName -> TopicName -> GiteaT m URL
|
||||
repoTopicsOneURL o repo (TopicName topic) = (\repos -> repos / "topics" / topic) <$> reposURL o repo
|
||||
|
||||
@ -120,7 +123,8 @@ getTopics owner repo =
|
||||
{ auth } <- ask
|
||||
url <- repoTopicsPageURL owner repo { limit, page: n }
|
||||
rep <- HTTP.fetch $ HTTP.GET /\ url /\ Auth.headers auth
|
||||
Error.tryGetRepJSON rep
|
||||
{topics} <- Error.tryGetRepJSON @{topics :: Array TopicName} rep
|
||||
pure topics
|
||||
in
|
||||
tailRecM paginate ([] /\ 1)
|
||||
|
||||
@ -130,3 +134,10 @@ removeTopic owner repo topic = do
|
||||
url <- repoTopicsOneURL owner repo topic
|
||||
rep <- HTTP.fetch $ HTTP.DELETE /\ url /\ Auth.headers auth
|
||||
Error.guardStatusOk rep
|
||||
|
||||
setTopics :: forall m. MonadAff m => Username -> RepoName -> Array TopicName -> GiteaT m Unit
|
||||
setTopics owner repo topics = do
|
||||
{ auth } <- ask
|
||||
url <- repoTopicsURL owner repo
|
||||
rep <- HTTP.fetch $ HTTP.PUT /\ url /\ HTTP.json {topics} /\ Auth.headers auth
|
||||
Error.guardStatusOk rep
|
||||
|
Loading…
Reference in New Issue
Block a user