github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/project_summary.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package 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  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  )
    15  
    16  // ProjectSummary project summary
    17  //
    18  // swagger:model ProjectSummary
    19  type ProjectSummary struct {
    20  
    21  	// The total number of developer members.
    22  	DeveloperCount int64 `json:"developer_count,omitempty"`
    23  
    24  	// The total number of guest members.
    25  	GuestCount int64 `json:"guest_count,omitempty"`
    26  
    27  	// The total number of limited guest members.
    28  	LimitedGuestCount int64 `json:"limited_guest_count,omitempty"`
    29  
    30  	// The total number of maintainer members.
    31  	MaintainerCount int64 `json:"maintainer_count,omitempty"`
    32  
    33  	// The total number of project admin members.
    34  	ProjectAdminCount int64 `json:"project_admin_count,omitempty"`
    35  
    36  	// quota
    37  	Quota *ProjectSummaryQuota `json:"quota,omitempty"`
    38  
    39  	// registry
    40  	Registry *Registry `json:"registry,omitempty"`
    41  
    42  	// The number of the repositories under this project.
    43  	RepoCount int64 `json:"repo_count"`
    44  }
    45  
    46  // Validate validates this project summary
    47  func (m *ProjectSummary) Validate(formats strfmt.Registry) error {
    48  	var res []error
    49  
    50  	if err := m.validateQuota(formats); err != nil {
    51  		res = append(res, err)
    52  	}
    53  
    54  	if err := m.validateRegistry(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if len(res) > 0 {
    59  		return errors.CompositeValidationError(res...)
    60  	}
    61  	return nil
    62  }
    63  
    64  func (m *ProjectSummary) validateQuota(formats strfmt.Registry) error {
    65  	if swag.IsZero(m.Quota) { // not required
    66  		return nil
    67  	}
    68  
    69  	if m.Quota != nil {
    70  		if err := m.Quota.Validate(formats); err != nil {
    71  			if ve, ok := err.(*errors.Validation); ok {
    72  				return ve.ValidateName("quota")
    73  			} else if ce, ok := err.(*errors.CompositeError); ok {
    74  				return ce.ValidateName("quota")
    75  			}
    76  			return err
    77  		}
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *ProjectSummary) validateRegistry(formats strfmt.Registry) error {
    84  	if swag.IsZero(m.Registry) { // not required
    85  		return nil
    86  	}
    87  
    88  	if m.Registry != nil {
    89  		if err := m.Registry.Validate(formats); err != nil {
    90  			if ve, ok := err.(*errors.Validation); ok {
    91  				return ve.ValidateName("registry")
    92  			} else if ce, ok := err.(*errors.CompositeError); ok {
    93  				return ce.ValidateName("registry")
    94  			}
    95  			return err
    96  		}
    97  	}
    98  
    99  	return nil
   100  }
   101  
   102  // ContextValidate validate this project summary based on the context it is used
   103  func (m *ProjectSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   104  	var res []error
   105  
   106  	if err := m.contextValidateQuota(ctx, formats); err != nil {
   107  		res = append(res, err)
   108  	}
   109  
   110  	if err := m.contextValidateRegistry(ctx, formats); err != nil {
   111  		res = append(res, err)
   112  	}
   113  
   114  	if len(res) > 0 {
   115  		return errors.CompositeValidationError(res...)
   116  	}
   117  	return nil
   118  }
   119  
   120  func (m *ProjectSummary) contextValidateQuota(ctx context.Context, formats strfmt.Registry) error {
   121  
   122  	if m.Quota != nil {
   123  		if err := m.Quota.ContextValidate(ctx, formats); err != nil {
   124  			if ve, ok := err.(*errors.Validation); ok {
   125  				return ve.ValidateName("quota")
   126  			} else if ce, ok := err.(*errors.CompositeError); ok {
   127  				return ce.ValidateName("quota")
   128  			}
   129  			return err
   130  		}
   131  	}
   132  
   133  	return nil
   134  }
   135  
   136  func (m *ProjectSummary) contextValidateRegistry(ctx context.Context, formats strfmt.Registry) error {
   137  
   138  	if m.Registry != nil {
   139  		if err := m.Registry.ContextValidate(ctx, formats); err != nil {
   140  			if ve, ok := err.(*errors.Validation); ok {
   141  				return ve.ValidateName("registry")
   142  			} else if ce, ok := err.(*errors.CompositeError); ok {
   143  				return ce.ValidateName("registry")
   144  			}
   145  			return err
   146  		}
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  // MarshalBinary interface implementation
   153  func (m *ProjectSummary) MarshalBinary() ([]byte, error) {
   154  	if m == nil {
   155  		return nil, nil
   156  	}
   157  	return swag.WriteJSON(m)
   158  }
   159  
   160  // UnmarshalBinary interface implementation
   161  func (m *ProjectSummary) UnmarshalBinary(b []byte) error {
   162  	var res ProjectSummary
   163  	if err := swag.ReadJSON(b, &res); err != nil {
   164  		return err
   165  	}
   166  	*m = res
   167  	return nil
   168  }