mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-18 15:55:30 +00:00
31 lines
692 B
JavaScript
31 lines
692 B
JavaScript
import { BaseService, RequestHelper } from '../infrastructure';
|
|
|
|
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/keys` : 'user/keys');
|
|
|
|
class UserKeys extends BaseService {
|
|
all({ userId }) {
|
|
return RequestHelper.get(this, url(userId));
|
|
}
|
|
|
|
create(title, key, { userId } = {}) {
|
|
return RequestHelper.post(this, url(userId), {
|
|
title,
|
|
key,
|
|
});
|
|
}
|
|
|
|
show(keyId) {
|
|
const kId = encodeURIComponent(keyId);
|
|
|
|
return RequestHelper.get(this, `user/keys/${kId}`);
|
|
}
|
|
|
|
remove(keyId, { userId } = {}) {
|
|
const kId = encodeURIComponent(keyId);
|
|
|
|
return RequestHelper.delete(this, `${url(userId)}/${kId}`);
|
|
}
|
|
}
|
|
|
|
export default UserKeys;
|