37 lines
1.2 KiB
TypeScript

import { BaseService } from '@gitbeaker/requester-utils';
import {
BaseRequestOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
export class ProtectedBranches extends BaseService {
all(projectId: string | number, options?: PaginatedRequestOptions) {
const pId = encodeURIComponent(projectId);
return RequestHelper.get(this, `projects/${pId}/protected_branches`, options);
}
protect(projectId: string | number, branchName: string, options?: BaseRequestOptions) {
const pId = encodeURIComponent(projectId);
return RequestHelper.post(this, `projects/${pId}/protected_branches`, {
name: branchName,
...options,
});
}
show(projectId: string | number, branchName: string, options?: Sudo) {
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
return RequestHelper.get(this, `projects/${pId}/protected_branches/${bName}`, options);
}
unprotect(projectId: string | number, branchName: string, options?: Sudo) {
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
return RequestHelper.del(this, `projects/${pId}/protected_branches/${bName}`, options);
}
}