@@ -6,12 +6,15 @@ namespace DevExcelerateApi.Models
66{
77 public class RepositoryRequestModel : DevExIssueRequestModel
88 {
9- [ YamlMember ( Alias = "owner" , Order = 10 ) ]
9+ [ YamlMember ( Alias = "owner" , Order = 9 ) ]
1010 public string ? RepositoryOwner { get ; set ; } // will be inherited from issue
1111
12- [ YamlMember ( Alias = "repository_name" , Order = 11 ) ]
12+ [ YamlMember ( Alias = "repository_name" , Order = 10 ) ]
1313 public string ? RepositoryName { get ; set ; }
1414
15+ [ YamlMember ( Alias = "new_repository_name" , Order = 11 ) ]
16+ public string ? NewRepositoryName { get ; set ; }
17+
1518 [ YamlMember ( Alias = "visibility" , Order = 12 ) ]
1619 public string ? RepositoryVisibility { get ; set ; }
1720
@@ -42,42 +45,53 @@ public class RepositoryRequestModel : DevExIssueRequestModel
4245 [ YamlMember ( Alias = "contributors" , Order = 18 ) ]
4346 public List < string > ? ContributorList { get ; set ; }
4447
48+ [ YamlIgnore ]
49+ public string ? RemoveRepositoryMembers { get ; set ; }
50+
51+ [ YamlMember ( Alias = "remove_members" , Order = 19 ) ]
52+ public List < string > ? RemoveMemberList { get ; set ; }
53+
4554 [ YamlIgnore ]
4655 public string ? RepositoryRulesets { get ; set ; }
4756
48- [ YamlMember ( Alias = "rulesets" , Order = 19 ) ]
57+ [ YamlMember ( Alias = "rulesets" , Order = 20 ) ]
4958 public List < string > ? RulesetList { get ; set ; }
5059
5160 public static new RepositoryRequestModel Parse ( IDictionary < string , object ? > values )
5261 {
5362 ArgumentNullException . ThrowIfNull ( values ) ;
5463
5564 values . TryGetValue ( "repository_name" , out var repositoryName ) ;
65+ values . TryGetValue ( "new_repository_name" , out var newRepositoryName ) ;
5666 values . TryGetValue ( "repository_visibility" , out var repositoryVisibility ) ;
5767 values . TryGetValue ( "repository_classification" , out var repositoryClassification ) ;
5868 values . TryGetValue ( "repository_description" , out var repositoryDescription ) ;
5969 values . TryGetValue ( "repository_maintainers" , out var repositoryMaintainers ) ;
6070 values . TryGetValue ( "repository_readers" , out var repositoryReaders ) ;
6171 values . TryGetValue ( "repository_contributors" , out var repositoryContributors ) ;
6272 values . TryGetValue ( "repository_rulesets" , out var repositoryRulesets ) ;
73+ values . TryGetValue ( "remove_repository_members" , out var removeRepositoryMembers ) ;
6374
6475 if ( repositoryName == null )
6576 {
6677 // Fallback to the localized string if the default key is not found
6778 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_name" ) , out repositoryName ) ;
79+ values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "new_repository_name" ) , out newRepositoryName ) ;
6880 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_visibility" ) , out repositoryVisibility ) ;
6981 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_classification" ) , out repositoryClassification ) ;
7082 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_description" ) , out repositoryDescription ) ;
7183 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_maintainers" ) , out repositoryMaintainers ) ;
7284 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_readers" ) , out repositoryReaders ) ;
7385 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_contributors" ) , out repositoryContributors ) ;
7486 values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "repository_rulesets" ) , out repositoryRulesets ) ;
87+ values . TryGetValue ( LocalizationExtensions . GetLocalizedString ( "remove_repository_members" ) , out removeRepositoryMembers ) ;
7588 }
7689
7790 return new RepositoryRequestModel
7891 {
7992 RequestType = DevExIssueRequestModel . Parse ( values ) . RequestType ,
8093 RepositoryName = repositoryName ? . ToString ( ) ? . SanitizeResourceName ( ) ,
94+ NewRepositoryName = newRepositoryName ? . ToString ( ) ? . SanitizeResourceName ( ) ,
8195 RepositoryVisibility = repositoryVisibility ? . ToString ( ) ,
8296 RepositoryClassification = repositoryClassification ? . ToString ( ) ,
8397 RepositoryDescription = repositoryDescription ? . ToString ( ) ,
@@ -87,21 +101,44 @@ public class RepositoryRequestModel : DevExIssueRequestModel
87101 ReaderList = repositoryReaders ? . ToString ( ) . ConvertCsvToList ( ) ,
88102 RepositoryContributors = repositoryContributors ? . ToString ( ) ,
89103 ContributorList = repositoryContributors ? . ToString ( ) . ConvertCsvToList ( ) ,
104+ RemoveRepositoryMembers = removeRepositoryMembers ? . ToString ( ) ,
105+ RemoveMemberList = removeRepositoryMembers ? . ToString ( ) . ConvertCsvToList ( ) ,
90106 RepositoryRulesets = repositoryRulesets ? . ToString ( ) ,
91107 RulesetList = repositoryRulesets ? . ToString ( ) . ConvertCsvToList ( )
92108 } ;
93109 }
94110
95- public bool IsValid ( )
111+ public bool IsValid => IsValidCreate ( ) || IsValidUpdate ( ) ;
112+
113+ public bool IsValidCreate ( )
96114 {
97- return ! string . IsNullOrEmpty ( RepositoryName ) &&
115+ return RequestType == RequestType . CREATE_REPOSITORY &&
116+ ! string . IsNullOrEmpty ( RepositoryName ) &&
98117 ! string . IsNullOrEmpty ( RepositoryVisibility ) &&
99118 ! string . IsNullOrEmpty ( RepositoryClassification ) &&
100119 ! string . IsNullOrEmpty ( RepositoryDescription ) &&
101120 ContributorList ? . Count > 0 &&
102121 RulesetList ? . Count > 0 ;
103122 }
104123
124+ public bool IsValidUpdate ( )
125+ {
126+ return RequestType == RequestType . UPDATE_REPOSITORY &&
127+ ! string . IsNullOrEmpty ( RepositoryName ) &&
128+ // At least one change
129+ (
130+ ! string . IsNullOrEmpty ( NewRepositoryName ) ||
131+ ! string . IsNullOrEmpty ( RepositoryDescription ) ||
132+ ! string . IsNullOrEmpty ( RepositoryVisibility ) ||
133+ ! string . IsNullOrEmpty ( RepositoryClassification ) ||
134+ ! string . IsNullOrEmpty ( RepositoryMaintainers ) ||
135+ ! string . IsNullOrEmpty ( RepositoryReaders ) ||
136+ ! string . IsNullOrEmpty ( RepositoryContributors ) ||
137+ ! string . IsNullOrEmpty ( RemoveRepositoryMembers ) ||
138+ ! string . IsNullOrEmpty ( RepositoryRulesets )
139+ ) ;
140+ }
141+
105142 public string SerializeToYaml ( )
106143 {
107144 return YamlHelpers . Serialize ( this ) ;
0 commit comments