{-# LANGUAGE DataKinds #-}

module Hercules.API.Repos where

import Hercules.API.Accounts.Account (Account)
import Hercules.API.Prelude
import Hercules.API.Repos.Repo (Repo)
import Hercules.API.Repos.RepoKey (RepoKey)
import Servant.API
import Servant.API.Generic

data ReposAPI auth f = ReposAPI
  { ReposAPI auth f
-> f
   :- (Summary
         "Repositories that the account owns or has explicit access to."
       :> ("accounts"
           :> (Capture' '[Required, Strict] "accountId" (Id Account)
               :> ("repos" :> (auth :> Get '[JSON] [Repo])))))
reposByOwner ::
      f :- Summary "Repositories that the account owns or has explicit access to."
        :> "accounts"
        :> Capture' '[Required, Strict] "accountId" (Id Account)
        :> "repos"
        :> auth
        :> Get '[JSON] [Repo],
    ReposAPI auth f
-> f
   :- (Summary
         "Parse a git remote URL into site, owner and repo. Returns 400 if invalid, 404 if the site can not be determined. Does provide any guarantee that the repository exists."
       :> ("parse-git-url"
           :> (QueryParam' '[Required, Strict] "gitURL" Text
               :> (auth :> Get '[JSON] RepoKey))))
parseGitURL ::
      f :- Summary "Parse a git remote URL into site, owner and repo. Returns 400 if invalid, 404 if the site can not be determined. Does provide any guarantee that the repository exists."
        :> "parse-git-url"
        :> QueryParam' '[Required, Strict] "gitURL" Text
        :> auth
        :> Get '[JSON] RepoKey
  }
  deriving ((forall x. ReposAPI auth f -> Rep (ReposAPI auth f) x)
-> (forall x. Rep (ReposAPI auth f) x -> ReposAPI auth f)
-> Generic (ReposAPI auth f)
forall x. Rep (ReposAPI auth f) x -> ReposAPI auth f
forall x. ReposAPI auth f -> Rep (ReposAPI auth f) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall auth f x. Rep (ReposAPI auth f) x -> ReposAPI auth f
forall auth f x. ReposAPI auth f -> Rep (ReposAPI auth f) x
$cto :: forall auth f x. Rep (ReposAPI auth f) x -> ReposAPI auth f
$cfrom :: forall auth f x. ReposAPI auth f -> Rep (ReposAPI auth f) x
Generic)