diff --git a/README.md b/README.md index 42eb9adb1..6805b3672 100644 --- a/README.md +++ b/README.md @@ -64,18 +64,20 @@ const api = new Gitlab({ Available instantiating options: -| Name | Optional | Default | Description | -| -------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------- | -| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL | -| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) | -| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) | -| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) | -| `rejectUnauthorized` | Yes | `false` | Http Certificate setting | -| `sudo` | Yes | `false` | Sudo query parameter | -| `version` | Yes | `v4` | API Version ID | -| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys | -| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. | -| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms | +| Name | Optional | Default | Description | +| -------------------- | -------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL | +| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) | +| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) | +| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) | +| `rejectUnauthorized` | Yes | `false` | Http Certificate setting | +| `sudo` | Yes | `false` | Sudo query parameter | +| `version` | Yes | `v4` | API Version ID | +| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys | +| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. | +| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms | +| `profileToken` | Yes | N/A | [Requests Profiles Token](https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html) | +| `profileMode` | Yes | `execution` | [Requests Profiles Token](https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html) | ### CLI Support diff --git a/src/bin/index.ts b/src/bin/index.ts index 1dadac7f2..0c669b6cd 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -35,7 +35,9 @@ Object.entries(map).forEach(([name, methods]: [string, { name: string; args: str type: 'number', }) .option('gl-sudo', { type: 'string' }) - .option('gl-camelize', { type: 'boolean' }); + .option('gl-camelize', { type: 'boolean' }) + .option('gl-profile-token', { type: 'string' }) + .option('gl-profile-mode', { type: 'string' }); for (let i = 1; i < methods.length; i += 1) { const m = methods[i]; diff --git a/src/core/infrastructure/BaseService.ts b/src/core/infrastructure/BaseService.ts index c79a19681..2ba65b718 100644 --- a/src/core/infrastructure/BaseService.ts +++ b/src/core/infrastructure/BaseService.ts @@ -14,6 +14,8 @@ export class BaseService { jobToken, oauthToken, sudo, + profileToken, + profileMode = 'execution', host = 'https://gitlab.com', url = '', version = 'v4', @@ -34,6 +36,13 @@ export class BaseService { else if (jobToken) this.headers['job-token'] = jobToken; else if (token) this.headers['private-token'] = token; + // Profiling + if (profileToken) { + this.headers['X-Profile-Token'] = profileToken; + + if (profileMode) this.headers['X-Profile-Mode'] = profileMode; + } + // Set sudo if (sudo) this.headers['Sudo'] = `${sudo}`; } diff --git a/src/core/infrastructure/index.ts b/src/core/infrastructure/index.ts index 0829ccb8c..3c0bf8a1f 100644 --- a/src/core/infrastructure/index.ts +++ b/src/core/infrastructure/index.ts @@ -43,6 +43,8 @@ export interface BaseServiceOptions extends Sudo { camelize?: boolean; requester?: Requester; requestTimeout?: number; + profileToken?: string; + profileMode?: 'execution' | 'memory'; } // RequestHelper