public SshKey addSshKey ( Integer userId , String title , String key ) throws GitLabApiException { if ( userId == null ) { throw new RuntimeException ( "userId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "title" , title ) . withParam ( "key" , key ) ; Response response = post ( Response . Status . CREATED , formData , "users" , userId , "keys" ) ; SshKey sshKey = response . readEntity ( SshKey . class ) ; if ( sshKey != null ) { sshKey . setUserId ( userId ) ; } return ( sshKey ) ; }
Create new key owned by specified user . Available only for admin users .