feat: create branch protection

This commit is contained in:
orion 2023-11-28 16:22:18 -06:00
parent 2a4ee6482d
commit 8a806e9064
Signed by: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 9 additions and 2 deletions

View File

@ -8,9 +8,9 @@ import Data.URL (URL, (/))
import Effect.Aff.Class (class MonadAff) import Effect.Aff.Class (class MonadAff)
import Gitea.Auth as Auth import Gitea.Auth as Auth
import Gitea.Error as Error import Gitea.Error as Error
import Gitea.Trans (GiteaT)
import Gitea.Types (BranchProtection, BranchProtectionName(..), BranchProtectionUpdate, RepoName(..), Username(..))
import Gitea.HTTP (fetch) as HTTP import Gitea.HTTP (fetch) as HTTP
import Gitea.Trans (GiteaT)
import Gitea.Types (BranchProtection, BranchProtectionName(..), BranchProtectionUpdate, RepoName(..), Username(..), BranchProtectionCreate)
import HTTP (Method(..)) as HTTP import HTTP (Method(..)) as HTTP
import HTTP.Request (json) as HTTP import HTTP.Request (json) as HTTP
import Simple.JSON (class WriteForeign) import Simple.JSON (class WriteForeign)
@ -54,3 +54,9 @@ delete u r b = do
url <- branchProtectionOneURL u r b url <- branchProtectionOneURL u r b
rep <- HTTP.fetch $ HTTP.DELETE /\ url rep <- HTTP.fetch $ HTTP.DELETE /\ url
Error.guardStatusOk rep Error.guardStatusOk rep
create :: forall m. MonadAff m => Username -> RepoName -> Record BranchProtectionCreate -> GiteaT m (Record BranchProtection)
create u r new = do
url <- branchProtectionURL u r
rep <- HTTP.fetch $ HTTP.POST /\ url /\ HTTP.json new
Error.tryGetRepJSON rep

View File

@ -433,5 +433,6 @@ type BranchProtectionImmutable r =
| r | r
) )
type BranchProtectionCreate = (BranchProtectionMutable + BranchProtectionMutableOnCreate ())
type BranchProtectionUpdate = BranchProtectionMutable () type BranchProtectionUpdate = BranchProtectionMutable ()
type BranchProtection = (BranchProtectionMutable + BranchProtectionImmutable + BranchProtectionMutableOnCreate ()) type BranchProtection = (BranchProtectionMutable + BranchProtectionImmutable + BranchProtectionMutableOnCreate ())