module GitHub.Endpoints.Organizations.Teams (
teamsOfR,
teamInfoForR,
createTeamForR,
editTeamR,
deleteTeamR,
listTeamMembersR,
listTeamReposR,
addOrUpdateTeamRepoR,
teamMembershipInfoForR,
addTeamMembershipForR,
deleteTeamMembershipForR,
listTeamsCurrentR,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()
teamsOfR :: Name Organization -> FetchCount -> Request k (Vector SimpleTeam)
teamsOfR :: forall (k :: RW).
Name Organization -> FetchCount -> Request k (Vector SimpleTeam)
teamsOfR Name Organization
org =
Paths -> QueryString -> FetchCount -> Request k (Vector SimpleTeam)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"teams"] []
teamInfoForR :: Id Team -> Request k Team
teamInfoForR :: forall (k :: RW). Id Team -> Request k Team
teamInfoForR Id Team
tid =
Paths -> QueryString -> Request k Team
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid] []
createTeamForR :: Name Organization -> CreateTeam -> Request 'RW Team
createTeamForR :: Name Organization -> CreateTeam -> Request 'RW Team
createTeamForR Name Organization
org CreateTeam
cteam =
CommandMethod -> Paths -> ByteString -> Request 'RW Team
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"teams"] (CreateTeam -> ByteString
forall a. ToJSON a => a -> ByteString
encode CreateTeam
cteam)
editTeamR :: Id Team -> EditTeam -> Request 'RW Team
editTeamR :: Id Team -> EditTeam -> Request 'RW Team
editTeamR Id Team
tid EditTeam
eteam =
CommandMethod -> Paths -> ByteString -> Request 'RW Team
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Patch [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid] (EditTeam -> ByteString
forall a. ToJSON a => a -> ByteString
encode EditTeam
eteam)
deleteTeamR :: Id Team -> GenRequest 'MtUnit 'RW ()
deleteTeamR :: Id Team -> GenRequest 'MtUnit 'RW ()
deleteTeamR Id Team
tid =
CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid] ByteString
forall a. Monoid a => a
mempty
listTeamMembersR :: Id Team -> TeamMemberRole -> FetchCount -> Request 'RA (Vector SimpleUser)
listTeamMembersR :: Id Team
-> TeamMemberRole -> FetchCount -> Request 'RA (Vector SimpleUser)
listTeamMembersR Id Team
tid TeamMemberRole
r =
Paths
-> QueryString -> FetchCount -> Request 'RA (Vector SimpleUser)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"members"] [(ByteString
"role", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
r')]
where
r' :: ByteString
r' = case TeamMemberRole
r of
TeamMemberRole
TeamMemberRoleAll -> ByteString
"all"
TeamMemberRole
TeamMemberRoleMaintainer -> ByteString
"maintainer"
TeamMemberRole
TeamMemberRoleMember -> ByteString
"member"
listTeamReposR :: Id Team -> FetchCount -> Request k (Vector Repo)
listTeamReposR :: forall (k :: RW). Id Team -> FetchCount -> Request k (Vector Repo)
listTeamReposR Id Team
tid =
Paths -> QueryString -> FetchCount -> Request k (Vector Repo)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"repos"] []
addOrUpdateTeamRepoR :: Id Team -> Name Organization -> Name Repo -> Permission -> GenRequest 'MtUnit 'RW ()
addOrUpdateTeamRepoR :: Id Team
-> Name Organization
-> Name Repo
-> Permission
-> GenRequest 'MtUnit 'RW ()
addOrUpdateTeamRepoR Id Team
tid Name Organization
org Name Repo
repo Permission
permission =
CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"repos", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo] (AddTeamRepoPermission -> ByteString
forall a. ToJSON a => a -> ByteString
encode (AddTeamRepoPermission -> ByteString)
-> AddTeamRepoPermission -> ByteString
forall a b. (a -> b) -> a -> b
$ Permission -> AddTeamRepoPermission
AddTeamRepoPermission Permission
permission)
teamMembershipInfoForR :: Id Team -> Name Owner -> Request k TeamMembership
teamMembershipInfoForR :: forall (k :: RW). Id Team -> Name Owner -> Request k TeamMembership
teamMembershipInfoForR Id Team
tid Name Owner
user =
Paths -> QueryString -> Request k TeamMembership
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"memberships", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user] []
addTeamMembershipForR :: Id Team -> Name Owner -> Role -> Request 'RW TeamMembership
addTeamMembershipForR :: Id Team -> Name Owner -> Role -> Request 'RW TeamMembership
addTeamMembershipForR Id Team
tid Name Owner
user Role
role =
CommandMethod -> Paths -> ByteString -> Request 'RW TeamMembership
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Put [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"memberships", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user] (CreateTeamMembership -> ByteString
forall a. ToJSON a => a -> ByteString
encode (CreateTeamMembership -> ByteString)
-> CreateTeamMembership -> ByteString
forall a b. (a -> b) -> a -> b
$ Role -> CreateTeamMembership
CreateTeamMembership Role
role)
deleteTeamMembershipForR :: Id Team -> Name Owner -> GenRequest 'MtUnit 'RW ()
deleteTeamMembershipForR :: Id Team -> Name Owner -> GenRequest 'MtUnit 'RW ()
deleteTeamMembershipForR Id Team
tid Name Owner
user =
CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete [Text
"teams", Id Team -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Team
tid, Text
"memberships", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user] ByteString
forall a. Monoid a => a
mempty
listTeamsCurrentR :: FetchCount -> Request 'RA (Vector Team)
listTeamsCurrentR :: FetchCount -> Request 'RA (Vector Team)
listTeamsCurrentR =
Paths -> QueryString -> FetchCount -> Request 'RA (Vector Team)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"user", Text
"teams"] []