Skip to content

Commit

Permalink
Add ServiceAccount creation options
Browse files Browse the repository at this point in the history
Fixes #3559

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
  • Loading branch information
Scrumplex committed Mar 19, 2024
1 parent 1431e84 commit 7fdc7b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx --no-install lint-staged
yarn test
7 changes: 6 additions & 1 deletion packages/core/src/resources/GroupServiceAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import type { AccessTokenSchema } from '../templates/ResourceAccessTokens';
import { RequestHelper, endpoint } from '../infrastructure';
import type { GitlabAPIResponse, MappedOmit, ShowExpanded, Sudo } from '../infrastructure';

export interface GroupServiceAccountCreateOptions {
name?: string;
username?: string;
}

export interface GroupServiceAccountSchema extends Record<string, unknown> {
id: number;
username: string;
Expand All @@ -14,7 +19,7 @@ export type ServiceAccountAccessTokenSchema = MappedOmit<AccessTokenSchema, 'acc
export class GroupServiceAccounts<C extends boolean = false> extends BaseResource<C> {
create<E extends boolean = false>(
groupId: string | number,
options?: Sudo & ShowExpanded<E>,
options?: GroupServiceAccountCreateOptions & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<GroupServiceAccountSchema, C, E, void>> {
return RequestHelper.post<GroupServiceAccountSchema>()(
this,
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/resources/ServiceAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type { GitlabAPIResponse, ShowExpanded, Sudo } from '../infrastructure';

export interface ServiceAccountCreateOptions {
name?: string;
username?: string;
}

export interface ServiceAccountSchema extends Record<string, unknown> {
id: number;
name: string;
Expand All @@ -14,7 +19,7 @@ export interface ServiceAccountSchema extends Record<string, unknown> {

export class ServiceAccounts<C extends boolean = false> extends BaseResource<C> {
create<E extends boolean = false>(
options?: Sudo & ShowExpanded<E>,
options?: ServiceAccountCreateOptions & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<ServiceAccountSchema, C, E, void>> {
return RequestHelper.post<ServiceAccountSchema>()(this, endpoint`service_accounts`, options);
}
Expand Down

0 comments on commit 7fdc7b9

Please sign in to comment.