Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
907f86dd
Commit
907f86dd
authored
Mar 07, 2015
by
Lars Avery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding user ssh key api calls and ssh key model
parent
a6c11767
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+44
-0
GitlabSSHKey.java
src/main/java/org/gitlab/api/models/GitlabSSHKey.java
+37
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
907f86dd
...
...
@@ -212,6 +212,50 @@ public class GitlabAPI {
return
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
GitlabUser
.
class
);
}
/**
* Create a new ssh key for the user
*
* @param targetUserId The id of the Gitlab user
* @param title The title of the ssh key
* @param key The public key
* @return The new GitlabSSHKey
* @throws IOException
*/
public
GitlabSSHKey
createSSHKey
(
Integer
targetUserId
,
String
title
,
String
key
)
throws
IOException
{
Query
query
=
new
Query
()
.
append
(
"title"
,
title
)
.
append
(
"key"
,
key
);
String
tailUrl
=
GitlabUser
.
USERS_URL
+
"/"
+
targetUserId
+
GitlabSSHKey
.
KEYS_URL
+
query
.
toString
();
return
dispatch
().
to
(
tailUrl
,
GitlabSSHKey
.
class
);
}
/**
* Delete user's ssh key
*
* @param targetUserId The id of the Gitlab user
* @param targetKeyId The id of the Gitlab ssh key
* @throws IOException
*/
public
void
deleteSSHKey
(
Integer
targetUserId
,
Integer
targetKeyId
)
throws
IOException
{
String
tailUrl
=
GitlabUser
.
USERS_URL
+
"/"
+
targetUserId
+
GitlabSSHKey
.
KEYS_URL
+
"/"
+
targetKeyId
;
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
Void
.
class
);
}
/**
* Gets all ssh keys for a user
*
* @param targetUserId The id of the GitLab User
* @return The list of user ssh keys
*/
public
List
<
GitlabSSHKey
>
getSSHKeys
(
Integer
targetUserId
)
throws
IOException
{
String
tailUrl
=
GitlabUser
.
USERS_URL
+
"/"
+
targetUserId
+
GitlabSSHKey
.
KEYS_URL
;
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabSSHKey
[].
class
));
}
/**
* Delete a user
*
...
...
src/main/java/org/gitlab/api/models/GitlabSSHKey.java
0 → 100644
View file @
907f86dd
package
org
.
gitlab
.
api
.
models
;
import
org.codehaus.jackson.annotate.JsonProperty
;
import
java.util.Date
;
public
class
GitlabSSHKey
{
public
static
String
KEYS_URL
=
"/keys"
;
private
Integer
_id
;
private
String
_title
;
private
String
_key
;
public
Integer
getId
()
{
return
_id
;
}
public
void
setId
(
Integer
id
)
{
_id
=
id
;
}
public
String
getTitle
()
{
return
_title
;
}
public
void
setTitle
(
String
title
)
{
_title
=
title
;
}
public
String
getKey
()
{
return
_key
;
}
public
void
setKey
(
String
key
)
{
_key
=
key
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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