github.com/minio/console@v1.4.1/models/ldap_entities.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package models
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the swagger generate command
    24  
    25  import (
    26  	"context"
    27  	"strconv"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/strfmt"
    31  	"github.com/go-openapi/swag"
    32  )
    33  
    34  // LdapEntities ldap entities
    35  //
    36  // swagger:model ldapEntities
    37  type LdapEntities struct {
    38  
    39  	// groups
    40  	Groups []*LdapGroupPolicyEntity `json:"groups"`
    41  
    42  	// policies
    43  	Policies []*LdapPolicyEntity `json:"policies"`
    44  
    45  	// timestamp
    46  	Timestamp string `json:"timestamp,omitempty"`
    47  
    48  	// users
    49  	Users []*LdapUserPolicyEntity `json:"users"`
    50  }
    51  
    52  // Validate validates this ldap entities
    53  func (m *LdapEntities) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateGroups(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validatePolicies(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if err := m.validateUsers(formats); err != nil {
    65  		res = append(res, err)
    66  	}
    67  
    68  	if len(res) > 0 {
    69  		return errors.CompositeValidationError(res...)
    70  	}
    71  	return nil
    72  }
    73  
    74  func (m *LdapEntities) validateGroups(formats strfmt.Registry) error {
    75  	if swag.IsZero(m.Groups) { // not required
    76  		return nil
    77  	}
    78  
    79  	for i := 0; i < len(m.Groups); i++ {
    80  		if swag.IsZero(m.Groups[i]) { // not required
    81  			continue
    82  		}
    83  
    84  		if m.Groups[i] != nil {
    85  			if err := m.Groups[i].Validate(formats); err != nil {
    86  				if ve, ok := err.(*errors.Validation); ok {
    87  					return ve.ValidateName("groups" + "." + strconv.Itoa(i))
    88  				} else if ce, ok := err.(*errors.CompositeError); ok {
    89  					return ce.ValidateName("groups" + "." + strconv.Itoa(i))
    90  				}
    91  				return err
    92  			}
    93  		}
    94  
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  func (m *LdapEntities) validatePolicies(formats strfmt.Registry) error {
   101  	if swag.IsZero(m.Policies) { // not required
   102  		return nil
   103  	}
   104  
   105  	for i := 0; i < len(m.Policies); i++ {
   106  		if swag.IsZero(m.Policies[i]) { // not required
   107  			continue
   108  		}
   109  
   110  		if m.Policies[i] != nil {
   111  			if err := m.Policies[i].Validate(formats); err != nil {
   112  				if ve, ok := err.(*errors.Validation); ok {
   113  					return ve.ValidateName("policies" + "." + strconv.Itoa(i))
   114  				} else if ce, ok := err.(*errors.CompositeError); ok {
   115  					return ce.ValidateName("policies" + "." + strconv.Itoa(i))
   116  				}
   117  				return err
   118  			}
   119  		}
   120  
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  func (m *LdapEntities) validateUsers(formats strfmt.Registry) error {
   127  	if swag.IsZero(m.Users) { // not required
   128  		return nil
   129  	}
   130  
   131  	for i := 0; i < len(m.Users); i++ {
   132  		if swag.IsZero(m.Users[i]) { // not required
   133  			continue
   134  		}
   135  
   136  		if m.Users[i] != nil {
   137  			if err := m.Users[i].Validate(formats); err != nil {
   138  				if ve, ok := err.(*errors.Validation); ok {
   139  					return ve.ValidateName("users" + "." + strconv.Itoa(i))
   140  				} else if ce, ok := err.(*errors.CompositeError); ok {
   141  					return ce.ValidateName("users" + "." + strconv.Itoa(i))
   142  				}
   143  				return err
   144  			}
   145  		}
   146  
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  // ContextValidate validate this ldap entities based on the context it is used
   153  func (m *LdapEntities) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   154  	var res []error
   155  
   156  	if err := m.contextValidateGroups(ctx, formats); err != nil {
   157  		res = append(res, err)
   158  	}
   159  
   160  	if err := m.contextValidatePolicies(ctx, formats); err != nil {
   161  		res = append(res, err)
   162  	}
   163  
   164  	if err := m.contextValidateUsers(ctx, formats); err != nil {
   165  		res = append(res, err)
   166  	}
   167  
   168  	if len(res) > 0 {
   169  		return errors.CompositeValidationError(res...)
   170  	}
   171  	return nil
   172  }
   173  
   174  func (m *LdapEntities) contextValidateGroups(ctx context.Context, formats strfmt.Registry) error {
   175  
   176  	for i := 0; i < len(m.Groups); i++ {
   177  
   178  		if m.Groups[i] != nil {
   179  
   180  			if swag.IsZero(m.Groups[i]) { // not required
   181  				return nil
   182  			}
   183  
   184  			if err := m.Groups[i].ContextValidate(ctx, formats); err != nil {
   185  				if ve, ok := err.(*errors.Validation); ok {
   186  					return ve.ValidateName("groups" + "." + strconv.Itoa(i))
   187  				} else if ce, ok := err.(*errors.CompositeError); ok {
   188  					return ce.ValidateName("groups" + "." + strconv.Itoa(i))
   189  				}
   190  				return err
   191  			}
   192  		}
   193  
   194  	}
   195  
   196  	return nil
   197  }
   198  
   199  func (m *LdapEntities) contextValidatePolicies(ctx context.Context, formats strfmt.Registry) error {
   200  
   201  	for i := 0; i < len(m.Policies); i++ {
   202  
   203  		if m.Policies[i] != nil {
   204  
   205  			if swag.IsZero(m.Policies[i]) { // not required
   206  				return nil
   207  			}
   208  
   209  			if err := m.Policies[i].ContextValidate(ctx, formats); err != nil {
   210  				if ve, ok := err.(*errors.Validation); ok {
   211  					return ve.ValidateName("policies" + "." + strconv.Itoa(i))
   212  				} else if ce, ok := err.(*errors.CompositeError); ok {
   213  					return ce.ValidateName("policies" + "." + strconv.Itoa(i))
   214  				}
   215  				return err
   216  			}
   217  		}
   218  
   219  	}
   220  
   221  	return nil
   222  }
   223  
   224  func (m *LdapEntities) contextValidateUsers(ctx context.Context, formats strfmt.Registry) error {
   225  
   226  	for i := 0; i < len(m.Users); i++ {
   227  
   228  		if m.Users[i] != nil {
   229  
   230  			if swag.IsZero(m.Users[i]) { // not required
   231  				return nil
   232  			}
   233  
   234  			if err := m.Users[i].ContextValidate(ctx, formats); err != nil {
   235  				if ve, ok := err.(*errors.Validation); ok {
   236  					return ve.ValidateName("users" + "." + strconv.Itoa(i))
   237  				} else if ce, ok := err.(*errors.CompositeError); ok {
   238  					return ce.ValidateName("users" + "." + strconv.Itoa(i))
   239  				}
   240  				return err
   241  			}
   242  		}
   243  
   244  	}
   245  
   246  	return nil
   247  }
   248  
   249  // MarshalBinary interface implementation
   250  func (m *LdapEntities) MarshalBinary() ([]byte, error) {
   251  	if m == nil {
   252  		return nil, nil
   253  	}
   254  	return swag.WriteJSON(m)
   255  }
   256  
   257  // UnmarshalBinary interface implementation
   258  func (m *LdapEntities) UnmarshalBinary(b []byte) error {
   259  	var res LdapEntities
   260  	if err := swag.ReadJSON(b, &res); err != nil {
   261  		return err
   262  	}
   263  	*m = res
   264  	return nil
   265  }