Justin Dalrymple 502d8180a7
Update service typing and peripheral endpoints (#1768)
* Dependency and Configuration updates
* CHANGELOG and README updates
* Added support for camel case and snake case response types in the request helper and base service
* Added support for the Dockerfile Templates API
* Added support for the Issue Note Award Emojis API
* Removed redundant Group Projects service
* Updated types for a variety of services
* Added type updates and removed protect and unprotect endpoints from the Branches API 
* Added type updates and signature endpoint to the Commits API
* Added type updates and edit support to the Deployments API
* Added type updates and a showRepository function to the Container Registry API
* Added type updates and updated the service support to include create, edit, show and remove for the Feature Flags API
* Added type updates and support for the removal of geonodes with the Geo Nodes API
* Renamed UserKeys to UserSSHKeys and added type updates for the User SSH Keys API
* Added type updates for the License Templates API and renamed the export to fix the spelling error
* Added type updates and support for the transfer projects endpoint for the Groups API
* Added type updates and removed removed events endpoint on the Projects API
* Added type updates and modified the create function to require a resource name in the Todos API
2021-05-14 10:07:11 -04:00

97 lines
2.3 KiB
TypeScript

import { BaseService } from '@gitbeaker/requester-utils';
import {
RequestHelper,
BaseRequestOptions,
PaginatedRequestOptions,
Sudo,
} from '../infrastructure';
export type SupportedService =
| 'asana'
| 'assembla'
| 'bamboo'
| 'bugzilla'
| 'buildkite'
| 'campfire'
| 'custom-issue-tracker'
| 'drone-ci'
| 'emails-on-push'
| 'external-wiki'
| 'flowdock'
| 'hangouts_chat'
| 'hipchat'
| 'irker'
| 'jira'
| 'kubernetes'
| 'slack-slash-commands'
| 'slack'
| 'packagist'
| 'pipelines-email'
| 'pivotaltracker'
| 'prometheus'
| 'pushover'
| 'redmine'
| 'microsoft-teams'
| 'mattermost'
| 'mattermost-slash-commands'
| 'teamcity'
| 'jenkins'
| 'jenkins-deprecated'
| 'mock-ci'
| 'youtrack';
export interface ServiceSchema extends Record<string, unknown> {
id: number;
title: string;
slug: string;
created_at: string;
updated_at: string;
active: boolean;
commit_events: boolean;
push_events: boolean;
issues_events: boolean;
confidential_issues_events: boolean;
merge_requests_events: boolean;
tag_push_events: boolean;
note_events: boolean;
confidential_note_events: boolean;
pipeline_events: boolean;
wiki_page_events: boolean;
job_events: boolean;
comment_on_event_enabled: boolean;
}
export class Services<C extends boolean = false> extends BaseService<C> {
all(projectId: string | number, options?: PaginatedRequestOptions) {
const pId = encodeURIComponent(projectId);
return RequestHelper.get<ServiceSchema[]>()(this, `projects/${pId}/services`, options);
}
edit(projectId: string | number, serviceName: SupportedService, options?: BaseRequestOptions) {
const pId = encodeURIComponent(projectId);
return RequestHelper.put<ServiceSchema>()(
this,
`projects/${pId}/services/${serviceName}`,
options,
);
}
remove(projectId: string | number, serviceName: SupportedService, options?: Sudo) {
const pId = encodeURIComponent(projectId);
return RequestHelper.del()(this, `projects/${pId}/services/${serviceName}`, options);
}
show(projectId: string | number, serviceName: SupportedService, options?: Sudo) {
const pId = encodeURIComponent(projectId);
return RequestHelper.get<ServiceSchema>()(
this,
`projects/${pId}/services/${serviceName}`,
options,
);
}
}