Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
1e29cfd2
Commit
1e29cfd2
authored
Jul 10, 2018
by
Greg Messner
Browse files
Added support for LDAP syncing (#223).
parent
8994a65d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
1e29cfd2
...
@@ -735,4 +735,76 @@ public class GroupApi extends AbstractApi {
...
@@ -735,4 +735,76 @@ public class GroupApi extends AbstractApi {
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
delete
(
expectedStatus
,
null
,
"groups"
,
groupId
,
"members"
,
userId
);
delete
(
expectedStatus
,
null
,
"groups"
,
groupId
,
"members"
,
userId
);
}
}
/**
* Syncs the group with its linked LDAP group. Only available to group owners and administrators.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/ldap_sync</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @throws GitLabApiException if any exception occurs
*/
public
void
ldapSync
(
Object
groupIdOrPath
)
throws
GitLabApiException
{
post
(
Response
.
Status
.
NO_CONTENT
,
(
Form
)
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"ldap_sync"
);
}
/**
* Adds an LDAP group link.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/ldap_group_links</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param cn the CN of a LDAP group
* @param groupAccess the minimum access level for members of the LDAP group
* @param provider the LDAP provider for the LDAP group
* @throws GitLabApiException if any exception occurs
*/
public
void
addLdapGroupLink
(
Object
groupIdOrPath
,
String
cn
,
AccessLevel
groupAccess
,
String
provider
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"cn"
,
cn
,
true
)
.
withParam
(
"group_Access"
,
groupAccess
,
true
)
.
withParam
(
"provider"
,
provider
,
true
);
post
(
Response
.
Status
.
NO_CONTENT
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"ldap_group_links"
);
}
/**
* Deletes an LDAP group link.
*
* <pre><code>GitLab Endpoint: DELETE /groups/:id/ldap_group_links/:cn</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param cn the CN of the LDAP group link to delete
* @throws GitLabApiException if any exception occurs
*/
public
void
deleteLdapGroupLink
(
Object
groupIdOrPath
,
String
cn
)
throws
GitLabApiException
{
if
(
cn
==
null
||
cn
.
trim
().
isEmpty
())
{
throw
new
RuntimeException
(
"cn cannot be null or empty"
);
}
delete
(
Response
.
Status
.
OK
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"ldap_group_links"
,
cn
);
}
/**
* Deletes an LDAP group link for a specific LDAP provider.
*
* <pre><code>GitLab Endpoint: DELETE /groups/:id/ldap_group_links/:provider/:cn</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param cn the CN of the LDAP group link to delete
* @param provider the name of the LDAP provider
* @throws GitLabApiException if any exception occurs
*/
public
void
deleteLdapGroupLink
(
Object
groupIdOrPath
,
String
cn
,
String
provider
)
throws
GitLabApiException
{
if
(
cn
==
null
||
cn
.
trim
().
isEmpty
())
{
throw
new
RuntimeException
(
"cn cannot be null or empty"
);
}
if
(
provider
==
null
||
provider
.
trim
().
isEmpty
())
{
throw
new
RuntimeException
(
"LDAP provider cannot be null or empty"
);
}
delete
(
Response
.
Status
.
OK
,
null
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"ldap_group_links"
,
provider
,
cn
);
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment