mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Remove the typings directory. Declare and use the types/interfaces in the various index.ts files. This will produce a package that can be used by Typescript without errors. Remove the typings directory. Declare and use the types/interfaces in the various index.ts files. This will produce a package that can be used by Typescript without errors.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { BaseService, RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
|
|
import { ProjectId } from '.';
|
|
|
|
class PushRule extends BaseService {
|
|
create(projectId: ProjectId, options?: BaseRequestOptions) {
|
|
const pId = encodeURIComponent(projectId);
|
|
|
|
return RequestHelper.post(this, `projects/${pId}/push_rule`, options);
|
|
}
|
|
|
|
edit(
|
|
projectId: ProjectId,
|
|
{ upsert = false, ...options }: { upsert: boolean } & BaseRequestOptions,
|
|
) {
|
|
const pId = encodeURIComponent(projectId);
|
|
|
|
try {
|
|
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
|
|
} catch (e) {
|
|
if (e.message.includes('exist')) return this.create(projectId, options);
|
|
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
remove(projectId: ProjectId, options?: Sudo) {
|
|
const pId = encodeURIComponent(projectId);
|
|
|
|
return RequestHelper.del(this, `projects/${pId}/push_rule`, options);
|
|
}
|
|
|
|
show(projectId: ProjectId, options?: Sudo) {
|
|
const pId = encodeURIComponent(projectId);
|
|
|
|
return RequestHelper.get(this, `projects/${pId}/push_rule`, options);
|
|
}
|
|
}
|
|
|
|
export default PushRule;
|