@@ -14,6 +14,20 @@ type ResetResponse struct {
1414 XToken string `json:"xtoken"`
1515}
1616
17+ type EmailResponse struct {
18+ Domains []string `json:"Domains"`
19+ ListType string `json:"ListType"`
20+ RegistrationType string `json:"RegistrationType"`
21+ }
22+
23+ type RegistrationRestrictionTypeSchema struct {
24+ SelectedRestrictionType string `json:"selectedRestrictionType"`
25+ }
26+
27+ type EmailWhiteBLackListSchema struct {
28+ Domains []string `json:"Domains"`
29+ }
30+
1731func ResetSecret () error {
1832
1933 // Restting the Secret
@@ -58,4 +72,41 @@ func ResetSecret() error {
5872 _ = cmdutil .WriteFile ("token.json" , lInfo )
5973 return nil
6074
75+ }
76+
77+ func GetEmailWhiteListBlackList () (* EmailResponse , error ) {
78+
79+ url := conf .AdminConsoleAPIDomain + "/security-configuration/restriction/config?"
80+ resp , err := request .Rest (http .MethodGet , url , nil , "" )
81+ if err != nil {
82+ return nil , err
83+ }
84+ var resObj EmailResponse
85+ err = json .Unmarshal (resp , & resObj )
86+ if err != nil {
87+ return nil , err
88+ }
89+ return & resObj , nil
90+
91+ }
92+
93+ func AddEmailWhitelistBlacklist (restrictionType RegistrationRestrictionTypeSchema , data EmailWhiteBLackListSchema ) error {
94+ typeUrl := conf .AdminConsoleAPIDomain + "/security-configuration/restriction/type?"
95+ body , _ := json .Marshal (restrictionType )
96+ _ , err := request .Rest (http .MethodPut , typeUrl , nil , string (body ))
97+
98+ if err != nil {
99+ return err
100+ }
101+
102+ if restrictionType .SelectedRestrictionType != "none" {
103+ domainUrl := conf .AdminConsoleAPIDomain + "/security-configuration/restriction/config?"
104+ body , _ := json .Marshal (data )
105+ _ , err := request .Rest (http .MethodPost , domainUrl , nil , string (body ))
106+
107+ if err != nil {
108+ return err
109+ }
110+ }
111+ return nil
61112}
0 commit comments