mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Gitbeaker has been split up into 5 subpackages: gitbeaker-core, gitbeaker-node, gitbeaker-cli, gitbeaker-browser and gitbeaker-requester-utils.
gitbeaker-[node,cli,browser] are enviroment
specific sub packages. For example, if you want to use gitbeaker in a NodeJS environment, use gitbeaker-node. gitbeaker-core is where all the
base logic exists, and gitbeaker-requester-utils is a collection of utility functions for making custom requester libraries.
BREAKING CHANGE: 🧨 This migration requires users to import specific subpackages. For NodeJS
usage, that would be @gitbeaker/node.
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import {
|
|
BaseRequestOptions,
|
|
BaseService,
|
|
PaginatedRequestOptions,
|
|
RequestHelper,
|
|
Sudo,
|
|
} from '../infrastructure';
|
|
|
|
export type SnippetVisibility = 'private' | 'public' | 'internal';
|
|
|
|
export class Snippets extends BaseService {
|
|
all({ public: p, ...options }: { public: boolean } & PaginatedRequestOptions) {
|
|
const url = p ? 'snippets/public' : 'snippets';
|
|
|
|
return RequestHelper.get(this, url, options);
|
|
}
|
|
|
|
content(snippetId: number, options?: Sudo) {
|
|
const sId = encodeURIComponent(snippetId);
|
|
|
|
return RequestHelper.get(this, `snippets/${sId}/raw`, options);
|
|
}
|
|
|
|
create(
|
|
title: string,
|
|
fileName: string,
|
|
content: string,
|
|
visibility: SnippetVisibility,
|
|
options?: BaseRequestOptions,
|
|
) {
|
|
return RequestHelper.post(this, 'snippets', {
|
|
title,
|
|
fileName,
|
|
content,
|
|
visibility,
|
|
...options,
|
|
});
|
|
}
|
|
|
|
edit(snippetId: number, options?: BaseRequestOptions) {
|
|
const sId = encodeURIComponent(snippetId);
|
|
|
|
return RequestHelper.put(this, `snippets/${sId}`, options);
|
|
}
|
|
|
|
remove(snippetId: number, options?: Sudo) {
|
|
const sId = encodeURIComponent(snippetId);
|
|
|
|
return RequestHelper.del(this, `snippets/${sId}`, options);
|
|
}
|
|
|
|
show(snippetId: number, options?: Sudo) {
|
|
const sId = encodeURIComponent(snippetId);
|
|
|
|
return RequestHelper.get(this, `snippets/${sId}`, options);
|
|
}
|
|
|
|
userAgentDetails(snippetId: number, options?: Sudo) {
|
|
const sId = encodeURIComponent(snippetId);
|
|
|
|
return RequestHelper.get(this, `snippets/${sId}/user_agent_detail`, options);
|
|
}
|
|
}
|