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
bbc07059
Unverified
Commit
bbc07059
authored
May 12, 2020
by
adamMo
Committed by
GitHub
May 11, 2020
Browse files
Added method for updating project deploy key (#570)
parent
eace5a40
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/DeployKeysApi.java
View file @
bbc07059
...
...
@@ -192,6 +192,33 @@ public class DeployKeysApi extends AbstractApi {
return
(
response
.
readEntity
(
DeployKey
.
class
));
}
/**
* Updates an existing project deploy key.
*
* <pre><code>GitLab Endpoint: PUT /projects/:id/deploy_keys/:key_id</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param deployKeyId the ID of the deploy key to update, required
* @param title the updated deploy key's title, optional
* @param canPush can deploy key push to the project's repository, optional
* @return an updated DeployKey instance
* @throws GitLabApiException if any exception occurs
*/
public
DeployKey
updateDeployKey
(
Object
projectIdOrPath
,
Integer
deployKeyId
,
String
title
,
Boolean
canPush
)
throws
GitLabApiException
{
if
(
deployKeyId
==
null
)
{
throw
new
RuntimeException
(
"deployKeyId cannot be null"
);
}
final
DeployKey
key
=
new
DeployKey
();
key
.
setCanPush
(
canPush
);
key
.
setTitle
(
title
);
final
Response
response
=
put
(
Response
.
Status
.
OK
,
key
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
,
deployKeyId
);
return
(
response
.
readEntity
(
DeployKey
.
class
));
}
/**
* Removes a deploy key from the project. If the deploy key is used only for this project,it will be deleted from the system.
*
...
...
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