github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/project.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  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // Project project
    18  //
    19  // swagger:model Project
    20  type Project struct {
    21  
    22  	// The creation time of the project.
    23  	// Format: date-time
    24  	CreationTime strfmt.DateTime `json:"creation_time,omitempty"`
    25  
    26  	// The role ID with highest permission of the current user who triggered the API (for UI).  This attribute is deprecated and will be removed in future versions.
    27  	CurrentUserRoleID int64 `json:"current_user_role_id,omitempty"`
    28  
    29  	// The list of role ID of the current user who triggered the API (for UI)
    30  	CurrentUserRoleIds []int32 `json:"current_user_role_ids"`
    31  
    32  	// The CVE allowlist of this project.
    33  	CVEAllowlist *CVEAllowlist `json:"cve_allowlist,omitempty"`
    34  
    35  	// A deletion mark of the project.
    36  	Deleted bool `json:"deleted,omitempty"`
    37  
    38  	// The metadata of the project.
    39  	Metadata *ProjectMetadata `json:"metadata,omitempty"`
    40  
    41  	// The name of the project.
    42  	Name string `json:"name,omitempty"`
    43  
    44  	// The owner ID of the project always means the creator of the project.
    45  	OwnerID int32 `json:"owner_id,omitempty"`
    46  
    47  	// The owner name of the project.
    48  	OwnerName string `json:"owner_name,omitempty"`
    49  
    50  	// Project ID
    51  	ProjectID int32 `json:"project_id,omitempty"`
    52  
    53  	// The ID of referenced registry when the project is a proxy cache project.
    54  	RegistryID int64 `json:"registry_id,omitempty"`
    55  
    56  	// The number of the repositories under this project.
    57  	RepoCount int64 `json:"repo_count"`
    58  
    59  	// Correspond to the UI about whether the project's publicity is  updatable (for UI)
    60  	Togglable bool `json:"togglable,omitempty"`
    61  
    62  	// The update time of the project.
    63  	// Format: date-time
    64  	UpdateTime strfmt.DateTime `json:"update_time,omitempty"`
    65  }
    66  
    67  // Validate validates this project
    68  func (m *Project) Validate(formats strfmt.Registry) error {
    69  	var res []error
    70  
    71  	if err := m.validateCreationTime(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validateCVEAllowlist(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateMetadata(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateUpdateTime(formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if len(res) > 0 {
    88  		return errors.CompositeValidationError(res...)
    89  	}
    90  	return nil
    91  }
    92  
    93  func (m *Project) validateCreationTime(formats strfmt.Registry) error {
    94  	if swag.IsZero(m.CreationTime) { // not required
    95  		return nil
    96  	}
    97  
    98  	if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil {
    99  		return err
   100  	}
   101  
   102  	return nil
   103  }
   104  
   105  func (m *Project) validateCVEAllowlist(formats strfmt.Registry) error {
   106  	if swag.IsZero(m.CVEAllowlist) { // not required
   107  		return nil
   108  	}
   109  
   110  	if m.CVEAllowlist != nil {
   111  		if err := m.CVEAllowlist.Validate(formats); err != nil {
   112  			if ve, ok := err.(*errors.Validation); ok {
   113  				return ve.ValidateName("cve_allowlist")
   114  			} else if ce, ok := err.(*errors.CompositeError); ok {
   115  				return ce.ValidateName("cve_allowlist")
   116  			}
   117  			return err
   118  		}
   119  	}
   120  
   121  	return nil
   122  }
   123  
   124  func (m *Project) validateMetadata(formats strfmt.Registry) error {
   125  	if swag.IsZero(m.Metadata) { // not required
   126  		return nil
   127  	}
   128  
   129  	if m.Metadata != nil {
   130  		if err := m.Metadata.Validate(formats); err != nil {
   131  			if ve, ok := err.(*errors.Validation); ok {
   132  				return ve.ValidateName("metadata")
   133  			} else if ce, ok := err.(*errors.CompositeError); ok {
   134  				return ce.ValidateName("metadata")
   135  			}
   136  			return err
   137  		}
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *Project) validateUpdateTime(formats strfmt.Registry) error {
   144  	if swag.IsZero(m.UpdateTime) { // not required
   145  		return nil
   146  	}
   147  
   148  	if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil {
   149  		return err
   150  	}
   151  
   152  	return nil
   153  }
   154  
   155  // ContextValidate validate this project based on the context it is used
   156  func (m *Project) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   157  	var res []error
   158  
   159  	if err := m.contextValidateCVEAllowlist(ctx, formats); err != nil {
   160  		res = append(res, err)
   161  	}
   162  
   163  	if err := m.contextValidateMetadata(ctx, formats); err != nil {
   164  		res = append(res, err)
   165  	}
   166  
   167  	if len(res) > 0 {
   168  		return errors.CompositeValidationError(res...)
   169  	}
   170  	return nil
   171  }
   172  
   173  func (m *Project) contextValidateCVEAllowlist(ctx context.Context, formats strfmt.Registry) error {
   174  
   175  	if m.CVEAllowlist != nil {
   176  		if err := m.CVEAllowlist.ContextValidate(ctx, formats); err != nil {
   177  			if ve, ok := err.(*errors.Validation); ok {
   178  				return ve.ValidateName("cve_allowlist")
   179  			} else if ce, ok := err.(*errors.CompositeError); ok {
   180  				return ce.ValidateName("cve_allowlist")
   181  			}
   182  			return err
   183  		}
   184  	}
   185  
   186  	return nil
   187  }
   188  
   189  func (m *Project) contextValidateMetadata(ctx context.Context, formats strfmt.Registry) error {
   190  
   191  	if m.Metadata != nil {
   192  		if err := m.Metadata.ContextValidate(ctx, formats); err != nil {
   193  			if ve, ok := err.(*errors.Validation); ok {
   194  				return ve.ValidateName("metadata")
   195  			} else if ce, ok := err.(*errors.CompositeError); ok {
   196  				return ce.ValidateName("metadata")
   197  			}
   198  			return err
   199  		}
   200  	}
   201  
   202  	return nil
   203  }
   204  
   205  // MarshalBinary interface implementation
   206  func (m *Project) MarshalBinary() ([]byte, error) {
   207  	if m == nil {
   208  		return nil, nil
   209  	}
   210  	return swag.WriteJSON(m)
   211  }
   212  
   213  // UnmarshalBinary interface implementation
   214  func (m *Project) UnmarshalBinary(b []byte) error {
   215  	var res Project
   216  	if err := swag.ReadJSON(b, &res); err != nil {
   217  		return err
   218  	}
   219  	*m = res
   220  	return nil
   221  }