Skip to content

Commit

Permalink
Merge pull request #1 from Ordina-Group/expand-create-team
Browse files Browse the repository at this point in the history
Added privacy and parent team id as additional parameters for creating a team
  • Loading branch information
Hayena committed Sep 13, 2023
2 parents 669ff8c + 7c4646f commit 29be8d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ internal object GitHubOrganizationClient {
return request(client).map { it.withOrganization(organizationName) }
}

fun createTeam(organizationName: String, teamName: String, description: String?): GitHubTeam {
fun createTeam(
organizationName: String,
teamName: String,
description: String? = null,
privacy: String = "secret",
parentTeamId: Int? = null
): GitHubTeam {
val lens = Body.auto<GetTeamResponse>().toLens()
val request = PostRequest("orgs/$organizationName/teams", CreateTeamRequest(teamName, description))
val body = CreateTeamRequest(teamName, description, privacy, parentTeamId)
val request = PostRequest("orgs/$organizationName/teams", body)

return lens(client(request)).withOrganization(organizationName)
}
Expand Down Expand Up @@ -109,7 +116,9 @@ internal object GitHubOrganizationClient {
@Serializable
internal data class CreateTeamRequest(
val name: String,
val description: String?
val description: String? = null,
val privacy: String = "secret",
val parent_team_id: Int? = null
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ data class GitHubOrganization internal constructor(
) {
fun getTeams(): List<GitHubTeam> = GitHubOrganizationClient.getTeams(login)

fun createTeam(teamName: String, teamDescription: String? = null): GitHubTeam =
GitHubOrganizationClient.createTeam(login, teamName, teamDescription)
fun createTeam(
teamName: String,
teamDescription: String? = null,
privacy: String = "secret",
parentTeamId: Int? = null
): GitHubTeam =
GitHubOrganizationClient.createTeam(login, teamName, teamDescription, privacy, parentTeamId)

fun getRepositories(): List<GitHubRepository> = GitHubOrganizationClient.getRepositories(login)
fun getMembers(): List<GitHubOrganizationMember> = GitHubOrganizationClient.getMembers(login)
Expand Down

0 comments on commit 29be8d0

Please sign in to comment.