import { BaseResource } from '@gitbeaker/requester-utils' ; import { BaseRequestOptions , PaginatedRequestOptions , ShowExpanded , RequestHelper , Sudo , endpoint , } from '../infrastructure' ; import { ProjectSchema } from './Projects' ; export interface GroupSchema extends Record < string , unknown > { id : number ; name : string ; path : string ; full_name : string ; full_path : string ; parent_id : number ; visibility : string ; avatar_url : string ; web_url : string ; description : string ; share_with_group_lock : boolean ; require_two_factor_authentication : boolean ; two_factor_grace_period : number ; project_creation_level : string ; auto_devops_enabled : boolean ; subgroup_creation_level : string ; emails_disabled : boolean ; mentions_disabled : boolean ; lfs_enabled : boolean ; default_branch_protection : number ; request_access_enabled : boolean ; file_template_project_id : number ; created_at : string ; } export type GroupDetailSchema = { id : number ; name : string ; path : string ; full_name : string ; full_path : string ; parent_id : number ; visibility : string ; avatar_url : string ; web_url : string ; description : string ; request_access_enabled : boolean ; file_template_project_id : number ; runners_token : string ; shared_with_groups : { group_id : number ; group_name : string ; group_full_path : string ; group_access_level : number ; expires_at : string ; } [ ] ; created_at : string ; } ; export class Groups < C extends boolean = false > extends BaseResource < C > { all ( options ? ) { return RequestHelper . get < GroupSchema [ ] > ( ) ( this , 'groups' , options ) ; } create ( name , path , options ? ) { return RequestHelper . post < GroupSchema > ( ) ( this , 'groups' , { name , path , ... options } ) ; } createLDAPLink ( groupId , cn , groupAccess , provider , options ? ) { return RequestHelper . post ( ) ( this , endpoint `groups/${ groupId }/ldap_group_links` , { cn , groupAccess , provider , ... options , } ) ; } edit ( groupId , options ? ) { return RequestHelper . put < GroupSchema > ( ) ( this , endpoint `groups/${ groupId }` , options ) ; } projects ( groupId , options ? ) { return RequestHelper . get < ProjectSchema [ ] > ( ) ( this , endpoint `groups/${ groupId }/projects` , options ) ; } remove ( groupId , options ? ) { return RequestHelper . del ( ) ( this , endpoint `groups/${ groupId }` , options ) ; } removeLDAPLink ( groupId , cn , { provider , ... options } = { } ) { const gId = encodeURIComponent ( groupId ) ; const url = provider ? `${ provider }/${ cn }` : `${ cn }` ; return RequestHelper . del ( ) ( this , `groups/${ gId }/ldap_group_links/${ url }` , options as Record < string , unknown > ) ; } search ( nameOrPath , options ? ) { return RequestHelper . get ( ) ( this , 'groups' , { search : nameOrPath , ... options , } ) ; } show ( groupId , options ? ) { return RequestHelper . get < GroupDetailSchema > ( ) ( this , endpoint `groups/${ groupId }` , options ) ; } subgroups ( groupId , options ? ) { return RequestHelper . get ( ) ( this , endpoint `groups/${ groupId }/subgroups` , options ) ; } syncLDAP ( groupId , options ? ) { return RequestHelper . post ( ) ( this , endpoint `groups/${ groupId }/ldap_sync` , options ) ; } transferProject ( groupId , projectId , options ? ) { return RequestHelper . post ( ) ( this , endpoint `groups/${ groupId }/projects/${ projectId }` , options ) ; } }