Skip to content

Commit 14b7023

Browse files
mironalAurelioDeRosa
authored andcommitted
feature(repository): support deploy key API
close #376
1 parent efb8c16 commit 14b7023

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

lib/Repository.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,49 @@ class Repository extends Requestable {
550550
return this._request('DELETE', `/repos/${this.__fullname}/hooks/${id}`, null, cb);
551551
}
552552

553+
/**
554+
* List the deploy keys for the repository
555+
* @see https://developer.github.com/v3/repos/keys/#list-deploy-keys
556+
* @param {Requestable.callback} cb - will receive the list of deploy keys
557+
* @return {Promise} - the promise for the http request
558+
*/
559+
listKeys(cb) {
560+
return this._request('GET', `/repos/${this.__fullname}/keys`, null, cb);
561+
}
562+
563+
/**
564+
* Get a deploy key for the repository
565+
* @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
566+
* @param {number} id - the id of the deploy key
567+
* @param {Requestable.callback} cb - will receive the details of the deploy key
568+
* @return {Promise} - the promise for the http request
569+
*/
570+
getKey(id, cb) {
571+
return this._request('GET', `/repos/${this.__fullname}/keys/${id}`, null, cb);
572+
}
573+
574+
/**
575+
* Add a new deploy key to the repository
576+
* @see https://developer.github.com/v3/repos/keys/#add-a-new-deploy-key
577+
* @param {Object} options - the configuration describing the new deploy key
578+
* @param {Requestable.callback} cb - will receive the new deploy key
579+
* @return {Promise} - the promise for the http request
580+
*/
581+
createKey(options, cb) {
582+
return this._request('POST', `/repos/${this.__fullname}/keys`, options, cb);
583+
}
584+
585+
/**
586+
* Delete a deploy key
587+
* @see https://developer.github.com/v3/repos/keys/#remove-a-deploy-key
588+
* @param {number} id - the id of the deploy key to be deleted
589+
* @param {Requestable.callback} cb - will receive true if the call is successful
590+
* @return {Promise} - the promise for the http request
591+
*/
592+
deleteKey(id, cb) {
593+
return this._request('DELETE', `/repos/${this.__fullname}/keys/${id}`, null, cb);
594+
}
595+
553596
/**
554597
* Delete a file from a branch
555598
* @see https://developer.github.com/v3/repos/contents/#delete-a-file

0 commit comments

Comments
 (0)