GitlabAccessLevelMapping.kt
/*
Copyright (C) 2026 Sber
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.archtool.vcs.provider.gitlab
import org.archtool.data.model.SeafPermission
object GitlabAccessLevelMapping {
private const val ACCESS_NO_ACCESS = 0
private const val ACCESS_MINIMAL = 5
private const val ACCESS_GUEST = 10
private const val ACCESS_PLANNER = 15
private const val ACCESS_REPORTER = 20
private const val ACCESS_DEVELOPER = 30
private const val ACCESS_MAINTAINER = 40
private const val ACCESS_OWNER = 50
/**
* Guest и уровни ниже Reporter не дают прав SEAF.
* Reporter → READ; Developer/Maintainer/Owner (>= 30) → WRITE.
*/
fun mapAccessLevel(accessLevel: Int): SeafPermission? =
when (accessLevel) {
ACCESS_NO_ACCESS,
ACCESS_MINIMAL,
ACCESS_GUEST,
ACCESS_PLANNER,
-> null
ACCESS_REPORTER -> SeafPermission.READ
ACCESS_DEVELOPER,
ACCESS_MAINTAINER,
ACCESS_OWNER,
-> SeafPermission.WRITE
else -> null
}
}