Skip to content

Commit

Permalink
Updating protected branched types (#3360)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple authored Jul 30, 2023
1 parent 2f12ab9 commit 007b7c9
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions packages/core/src/resources/ProtectedBranches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,47 @@ import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
OneOf,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';

export type ProtectedBranchAccessLevel = 0 | 30 | 40 | 60;
export interface ExtendedProtectedBranchAccessLevel {
export interface ExtendedProtectedBranchAccessLevelSchema {
id: number;
access_level: ProtectedBranchAccessLevel;
access_level_description: string;
user_id?: number;
group_id?: number;
user_id?: number | null;
group_id?: number | null;
}

export interface ProtectedBranchSchema extends Record<string, unknown> {
id: number;
name: string;
push_access_levels?: ExtendedProtectedBranchAccessLevel[];
merge_access_levels?: ExtendedProtectedBranchAccessLevel[];
unprotect_access_levels?: ExtendedProtectedBranchAccessLevel[];
push_access_levels?: ExtendedProtectedBranchAccessLevelSchema[];
merge_access_levels?: ExtendedProtectedBranchAccessLevelSchema[];
unprotect_access_levels?: ExtendedProtectedBranchAccessLevelSchema[];
allow_force_push: boolean;
code_owner_approval_required: boolean;
}

export type ProtectedBranchAllowOptions = OneOf<{
user_id: number;
group_id: number;
access_level: number;
}>;

export type EditsProtectedBranchAllowOptions = {
_destroy?: boolean;
} & ProtectedBranchAllowOptions;

export type CreateProtectedBranchOptions = {
allowForcePush?: boolean;
allowedToMerge?: Record<string, number>[];
allowedToPush?: Record<string, number>[];
allowedToUnprotect?: Record<string, number>[];
allowedToMerge?: ProtectedBranchAllowOptions[];
allowedToPush?: ProtectedBranchAllowOptions[];
allowedToUnprotect?: ProtectedBranchAllowOptions[];
codeOwnerApprovalRequired?: boolean;
mergeAccessLevel?: ProtectedBranchAccessLevel;
pushAccessLevel?: ProtectedBranchAccessLevel;
Expand All @@ -39,9 +51,9 @@ export type CreateProtectedBranchOptions = {

export type EditProtectedBranchOptions = {
allowForcePush?: boolean;
allowedToMerge?: Record<string, number>[];
allowedToPush?: Record<string, number>[];
allowedToUnprotect?: Record<string, number>[];
allowedToMerge?: EditsProtectedBranchAllowOptions[];
allowedToPush?: EditsProtectedBranchAllowOptions[];
allowedToUnprotect?: EditsProtectedBranchAllowOptions[];
codeOwnerApprovalRequired?: boolean;
};

Expand Down

0 comments on commit 007b7c9

Please sign in to comment.