2020import lombok .AllArgsConstructor ;
2121import lombok .Getter ;
2222
23+ import java .util .Optional ;
24+
2325@ AllArgsConstructor
2426public class DefectDojoConfig {
2527 @ Getter
@@ -37,15 +39,28 @@ public class DefectDojoConfig {
3739 @ Getter
3840 private final int maxPageCountForGets ;
3941
42+ /**
43+ * If not null, the id should be used instead of the username.
44+ */
45+ @ Getter
46+ private final Integer userId ;
47+
48+ public DefectDojoConfig (String url , String apiKey , String username , int maxPageCountForGets ) {
49+ this (url ,apiKey ,username , maxPageCountForGets , null );
50+ }
51+
4052 public static DefectDojoConfig fromEnv (){
4153 String url = System .getenv ("DEFECTDOJO_URL" );
4254 String username = System .getenv ("DEFECTDOJO_USERNAME" );
4355 String apiKey = System .getenv ("DEFECTDOJO_APIKEY" );
56+ Integer userId = Optional .ofNullable (System .getenv ("DEFECTDOJO_USER_ID" ))
57+ .map (Integer ::parseInt )
58+ .orElse (null );
4459
4560 int maxPageCountForGets = 100 ;
4661 if (System .getenv ("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS" ) != null ) {
4762 maxPageCountForGets = Integer .parseInt (System .getenv ("DEFECTDOJO_MAX_PAGE_COUNT_FOR_GETS" ));
4863 }
49- return new DefectDojoConfig (url , apiKey , username , maxPageCountForGets );
64+ return new DefectDojoConfig (url , apiKey , username , maxPageCountForGets , userId );
5065 }
5166}
0 commit comments