mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-10 11:15:08 +03:00
add create project branch endpoint
This commit is contained in:
parent
76dfe71b48
commit
07c725571d
@ -12,6 +12,7 @@ dependencies:
|
||||
- base
|
||||
- servant
|
||||
- text
|
||||
- unison-hash
|
||||
|
||||
ghc-options:
|
||||
-Wall
|
||||
|
@ -10,21 +10,28 @@ module Unison.Share.API.Projects
|
||||
|
||||
-- ** Create project
|
||||
CreateProjectAPI,
|
||||
CreateProjectRequest (..),
|
||||
CreateProjectResponse (..),
|
||||
|
||||
-- ** Create project branch
|
||||
CreateProjectBranchAPI,
|
||||
CreateProjectBranchRequest (..),
|
||||
CreateProjectBranchResponse (..),
|
||||
|
||||
-- * Types
|
||||
Project (..),
|
||||
ServerProjectId (..),
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Generics (Generic)
|
||||
import Servant.API
|
||||
import Unison.Hash32 (Hash32)
|
||||
|
||||
type ProjectsAPI =
|
||||
GetProjectAPI
|
||||
:<|> CreateProjectAPI
|
||||
:<|> CreateProjectBranchAPI
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
-- Get project
|
||||
@ -67,18 +74,54 @@ data CreateProjectResponse
|
||||
| CreateProjectResponseSuccess !Project
|
||||
deriving stock (Eq, Show)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
-- Create project branch
|
||||
|
||||
-- | [@POST /create-project-branch@]: Create a project branch
|
||||
type CreateProjectBranchAPI =
|
||||
"create-project-branch"
|
||||
:> ReqBody '[JSON] CreateProjectBranchRequest
|
||||
:> Verb Post 200 '[JSON] CreateProjectBranchResponse
|
||||
|
||||
-- | @POST /create-project-branch@ request.
|
||||
data CreateProjectBranchRequest = CreateProjectBranchRequest
|
||||
{ projectId :: Text,
|
||||
branchName :: Text,
|
||||
branchCausalHash :: Hash32,
|
||||
branchMergeTarget :: Maybe ProjectBranchIds
|
||||
}
|
||||
deriving stock (Eq, Show)
|
||||
|
||||
-- | @POST /create-project-branch@ response.
|
||||
data CreateProjectBranchResponse
|
||||
= -- | Request payload invalid.
|
||||
CreateProjectBranchResponseBadRequest
|
||||
| CreateProjectBranchResponseUnauthorized
|
||||
| CreateProjectBranchResponseSuccess !ProjectBranch
|
||||
deriving stock (Eq, Show)
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
-- Types
|
||||
|
||||
-- | A project.
|
||||
data Project = Project
|
||||
{ id :: ServerProjectId,
|
||||
{ id :: Text,
|
||||
name :: Text
|
||||
}
|
||||
deriving stock (Eq, Generic, Show)
|
||||
|
||||
-- | A project id that was generated on the server.
|
||||
newtype ServerProjectId = ServerProjectId
|
||||
{ unServerProjectId :: Text
|
||||
-- | A project branch.
|
||||
data ProjectBranch = ProjectBranch
|
||||
{ projectId :: Text,
|
||||
projectName :: Text,
|
||||
branchId :: Text,
|
||||
branchName :: Text
|
||||
}
|
||||
deriving newtype (Eq, Show)
|
||||
deriving stock (Eq, Generic, Show)
|
||||
|
||||
-- | A project id and branch id.
|
||||
data ProjectBranchIds = ProjectBranchIds
|
||||
{ projectId :: Text,
|
||||
branchId :: Text
|
||||
}
|
||||
deriving stock (Eq, Generic, Show)
|
||||
|
@ -53,4 +53,5 @@ library
|
||||
base
|
||||
, servant
|
||||
, text
|
||||
, unison-hash
|
||||
default-language: Haskell2010
|
||||
|
Loading…
Reference in New Issue
Block a user