@@ -24,13 +24,14 @@ import (
2424 "fmt"
2525 "net/url"
2626 "strconv"
27+ "strings"
2728)
2829
2930type LDAPServiceIface interface {
3031 AddLdapConfiguration (p * AddLdapConfigurationParams ) (* AddLdapConfigurationResponse , error )
3132 NewAddLdapConfigurationParams (hostname string , port int ) * AddLdapConfigurationParams
3233 DeleteLdapConfiguration (p * DeleteLdapConfigurationParams ) (* DeleteLdapConfigurationResponse , error )
33- NewDeleteLdapConfigurationParams (hostname string ) * DeleteLdapConfigurationParams
34+ NewDeleteLdapConfigurationParams () * DeleteLdapConfigurationParams
3435 ImportLdapUsers (p * ImportLdapUsersParams ) (* ImportLdapUsersResponse , error )
3536 NewImportLdapUsersParams () * ImportLdapUsersParams
3637 LdapConfig (p * LdapConfigParams ) (* LdapConfigResponse , error )
@@ -43,6 +44,7 @@ type LDAPServiceIface interface {
4344 NewLinkDomainToLdapParams (accounttype int , domainid string , lDAPType string ) * LinkDomainToLdapParams
4445 ListLdapConfigurations (p * ListLdapConfigurationsParams ) (* ListLdapConfigurationsResponse , error )
4546 NewListLdapConfigurationsParams () * ListLdapConfigurationsParams
47+ GetLdapConfigurationByID (id string , opts ... OptionFunc ) (* LdapConfiguration , int , error )
4648 ListLdapUsers (p * ListLdapUsersParams ) (* ListLdapUsersResponse , error )
4749 NewListLdapUsersParams () * ListLdapUsersParams
4850 SearchLdap (p * SearchLdapParams ) (* SearchLdapResponse , error )
@@ -162,6 +164,7 @@ func (s *LDAPService) AddLdapConfiguration(p *AddLdapConfigurationParams) (*AddL
162164type AddLdapConfigurationResponse struct {
163165 Domainid string `json:"domainid"`
164166 Hostname string `json:"hostname"`
167+ Id string `json:"id"`
165168 JobID string `json:"jobid"`
166169 Jobstatus int `json:"jobstatus"`
167170 Port int `json:"port"`
@@ -182,6 +185,9 @@ func (p *DeleteLdapConfigurationParams) toURLValues() url.Values {
182185 if v , found := p .p ["hostname" ]; found {
183186 u .Set ("hostname" , v .(string ))
184187 }
188+ if v , found := p .p ["id" ]; found {
189+ u .Set ("id" , v .(string ))
190+ }
185191 if v , found := p .p ["port" ]; found {
186192 vv := strconv .Itoa (v .(int ))
187193 u .Set ("port" , vv )
@@ -231,6 +237,27 @@ func (p *DeleteLdapConfigurationParams) GetHostname() (string, bool) {
231237 return value , ok
232238}
233239
240+ func (p * DeleteLdapConfigurationParams ) SetId (v string ) {
241+ if p .p == nil {
242+ p .p = make (map [string ]interface {})
243+ }
244+ p .p ["id" ] = v
245+ }
246+
247+ func (p * DeleteLdapConfigurationParams ) ResetId () {
248+ if p .p != nil && p .p ["id" ] != nil {
249+ delete (p .p , "id" )
250+ }
251+ }
252+
253+ func (p * DeleteLdapConfigurationParams ) GetId () (string , bool ) {
254+ if p .p == nil {
255+ p .p = make (map [string ]interface {})
256+ }
257+ value , ok := p .p ["id" ].(string )
258+ return value , ok
259+ }
260+
234261func (p * DeleteLdapConfigurationParams ) SetPort (v int ) {
235262 if p .p == nil {
236263 p .p = make (map [string ]interface {})
@@ -254,10 +281,9 @@ func (p *DeleteLdapConfigurationParams) GetPort() (int, bool) {
254281
255282// You should always use this function to get a new DeleteLdapConfigurationParams instance,
256283// as then you are sure you have configured all required params
257- func (s * LDAPService ) NewDeleteLdapConfigurationParams (hostname string ) * DeleteLdapConfigurationParams {
284+ func (s * LDAPService ) NewDeleteLdapConfigurationParams () * DeleteLdapConfigurationParams {
258285 p := & DeleteLdapConfigurationParams {}
259286 p .p = make (map [string ]interface {})
260- p .p ["hostname" ] = hostname
261287 return p
262288}
263289
@@ -279,6 +305,7 @@ func (s *LDAPService) DeleteLdapConfiguration(p *DeleteLdapConfigurationParams)
279305type DeleteLdapConfigurationResponse struct {
280306 Domainid string `json:"domainid"`
281307 Hostname string `json:"hostname"`
308+ Id string `json:"id"`
282309 JobID string `json:"jobid"`
283310 Jobstatus int `json:"jobstatus"`
284311 Port int `json:"port"`
@@ -1514,6 +1541,9 @@ func (p *ListLdapConfigurationsParams) toURLValues() url.Values {
15141541 if v , found := p .p ["hostname" ]; found {
15151542 u .Set ("hostname" , v .(string ))
15161543 }
1544+ if v , found := p .p ["id" ]; found {
1545+ u .Set ("id" , v .(string ))
1546+ }
15171547 if v , found := p .p ["keyword" ]; found {
15181548 u .Set ("keyword" , v .(string ))
15191549 }
@@ -1578,6 +1608,27 @@ func (p *ListLdapConfigurationsParams) GetHostname() (string, bool) {
15781608 return value , ok
15791609}
15801610
1611+ func (p * ListLdapConfigurationsParams ) SetId (v string ) {
1612+ if p .p == nil {
1613+ p .p = make (map [string ]interface {})
1614+ }
1615+ p .p ["id" ] = v
1616+ }
1617+
1618+ func (p * ListLdapConfigurationsParams ) ResetId () {
1619+ if p .p != nil && p .p ["id" ] != nil {
1620+ delete (p .p , "id" )
1621+ }
1622+ }
1623+
1624+ func (p * ListLdapConfigurationsParams ) GetId () (string , bool ) {
1625+ if p .p == nil {
1626+ p .p = make (map [string ]interface {})
1627+ }
1628+ value , ok := p .p ["id" ].(string )
1629+ return value , ok
1630+ }
1631+
15811632func (p * ListLdapConfigurationsParams ) SetKeyword (v string ) {
15821633 if p .p == nil {
15831634 p .p = make (map [string ]interface {})
@@ -1691,6 +1742,39 @@ func (s *LDAPService) NewListLdapConfigurationsParams() *ListLdapConfigurationsP
16911742 return p
16921743}
16931744
1745+ // This is a courtesy helper function, which in some cases may not work as expected!
1746+ func (s * LDAPService ) GetLdapConfigurationByID (id string , opts ... OptionFunc ) (* LdapConfiguration , int , error ) {
1747+ p := & ListLdapConfigurationsParams {}
1748+ p .p = make (map [string ]interface {})
1749+
1750+ p .p ["id" ] = id
1751+
1752+ for _ , fn := range append (s .cs .options , opts ... ) {
1753+ if err := fn (s .cs , p ); err != nil {
1754+ return nil , - 1 , err
1755+ }
1756+ }
1757+
1758+ l , err := s .ListLdapConfigurations (p )
1759+ if err != nil {
1760+ if strings .Contains (err .Error (), fmt .Sprintf (
1761+ "Invalid parameter id value=%s due to incorrect long value format, " +
1762+ "or entity does not exist" , id )) {
1763+ return nil , 0 , fmt .Errorf ("No match found for %s: %+v" , id , l )
1764+ }
1765+ return nil , - 1 , err
1766+ }
1767+
1768+ if l .Count == 0 {
1769+ return nil , l .Count , fmt .Errorf ("No match found for %s: %+v" , id , l )
1770+ }
1771+
1772+ if l .Count == 1 {
1773+ return l .LdapConfigurations [0 ], l .Count , nil
1774+ }
1775+ return nil , l .Count , fmt .Errorf ("There is more then one result for LdapConfiguration UUID: %s!" , id )
1776+ }
1777+
16941778// Lists all LDAP configurations
16951779func (s * LDAPService ) ListLdapConfigurations (p * ListLdapConfigurationsParams ) (* ListLdapConfigurationsResponse , error ) {
16961780 resp , err := s .cs .newRequest ("listLdapConfigurations" , p .toURLValues ())
@@ -1714,6 +1798,7 @@ type ListLdapConfigurationsResponse struct {
17141798type LdapConfiguration struct {
17151799 Domainid string `json:"domainid"`
17161800 Hostname string `json:"hostname"`
1801+ Id string `json:"id"`
17171802 JobID string `json:"jobid"`
17181803 Jobstatus int `json:"jobstatus"`
17191804 Port int `json:"port"`
0 commit comments