github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/usage_info.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"context"
    10  	"strconv"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // UsageInfo usage info
    19  //
    20  // swagger:model UsageInfo
    21  type UsageInfo struct {
    22  
    23  	// active users
    24  	ActiveUsers []*UsageInfoActiveUsersItems0 `json:"activeUsers"`
    25  
    26  	// grouping
    27  	Grouping string `json:"grouping,omitempty"`
    28  }
    29  
    30  // Validate validates this usage info
    31  func (m *UsageInfo) Validate(formats strfmt.Registry) error {
    32  	var res []error
    33  
    34  	if err := m.validateActiveUsers(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if len(res) > 0 {
    39  		return errors.CompositeValidationError(res...)
    40  	}
    41  	return nil
    42  }
    43  
    44  func (m *UsageInfo) validateActiveUsers(formats strfmt.Registry) error {
    45  	if swag.IsZero(m.ActiveUsers) { // not required
    46  		return nil
    47  	}
    48  
    49  	for i := 0; i < len(m.ActiveUsers); i++ {
    50  		if swag.IsZero(m.ActiveUsers[i]) { // not required
    51  			continue
    52  		}
    53  
    54  		if m.ActiveUsers[i] != nil {
    55  			if err := m.ActiveUsers[i].Validate(formats); err != nil {
    56  				if ve, ok := err.(*errors.Validation); ok {
    57  					return ve.ValidateName("activeUsers" + "." + strconv.Itoa(i))
    58  				}
    59  				return err
    60  			}
    61  		}
    62  
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  // ContextValidate validate this usage info based on the context it is used
    69  func (m *UsageInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    70  	var res []error
    71  
    72  	if err := m.contextValidateActiveUsers(ctx, formats); err != nil {
    73  		res = append(res, err)
    74  	}
    75  
    76  	if len(res) > 0 {
    77  		return errors.CompositeValidationError(res...)
    78  	}
    79  	return nil
    80  }
    81  
    82  func (m *UsageInfo) contextValidateActiveUsers(ctx context.Context, formats strfmt.Registry) error {
    83  
    84  	for i := 0; i < len(m.ActiveUsers); i++ {
    85  
    86  		if m.ActiveUsers[i] != nil {
    87  			if err := m.ActiveUsers[i].ContextValidate(ctx, formats); err != nil {
    88  				if ve, ok := err.(*errors.Validation); ok {
    89  					return ve.ValidateName("activeUsers" + "." + strconv.Itoa(i))
    90  				}
    91  				return err
    92  			}
    93  		}
    94  
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  // MarshalBinary interface implementation
   101  func (m *UsageInfo) MarshalBinary() ([]byte, error) {
   102  	if m == nil {
   103  		return nil, nil
   104  	}
   105  	return swag.WriteJSON(m)
   106  }
   107  
   108  // UnmarshalBinary interface implementation
   109  func (m *UsageInfo) UnmarshalBinary(b []byte) error {
   110  	var res UsageInfo
   111  	if err := swag.ReadJSON(b, &res); err != nil {
   112  		return err
   113  	}
   114  	*m = res
   115  	return nil
   116  }
   117  
   118  // UsageInfoActiveUsersItems0 usage info active users items0
   119  //
   120  // swagger:model UsageInfoActiveUsersItems0
   121  type UsageInfoActiveUsersItems0 struct {
   122  
   123  	// date
   124  	// Format: date
   125  	Date strfmt.Date `json:"date,omitempty"`
   126  
   127  	// users
   128  	Users int64 `json:"users,omitempty"`
   129  }
   130  
   131  // Validate validates this usage info active users items0
   132  func (m *UsageInfoActiveUsersItems0) Validate(formats strfmt.Registry) error {
   133  	var res []error
   134  
   135  	if err := m.validateDate(formats); err != nil {
   136  		res = append(res, err)
   137  	}
   138  
   139  	if len(res) > 0 {
   140  		return errors.CompositeValidationError(res...)
   141  	}
   142  	return nil
   143  }
   144  
   145  func (m *UsageInfoActiveUsersItems0) validateDate(formats strfmt.Registry) error {
   146  	if swag.IsZero(m.Date) { // not required
   147  		return nil
   148  	}
   149  
   150  	if err := validate.FormatOf("date", "body", "date", m.Date.String(), formats); err != nil {
   151  		return err
   152  	}
   153  
   154  	return nil
   155  }
   156  
   157  // ContextValidate validates this usage info active users items0 based on context it is used
   158  func (m *UsageInfoActiveUsersItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   159  	return nil
   160  }
   161  
   162  // MarshalBinary interface implementation
   163  func (m *UsageInfoActiveUsersItems0) MarshalBinary() ([]byte, error) {
   164  	if m == nil {
   165  		return nil, nil
   166  	}
   167  	return swag.WriteJSON(m)
   168  }
   169  
   170  // UnmarshalBinary interface implementation
   171  func (m *UsageInfoActiveUsersItems0) UnmarshalBinary(b []byte) error {
   172  	var res UsageInfoActiveUsersItems0
   173  	if err := swag.ReadJSON(b, &res); err != nil {
   174  		return err
   175  	}
   176  	*m = res
   177  	return nil
   178  }