github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/native_report_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  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // NativeReportSummary The summary for the native report
    18  //
    19  // swagger:model NativeReportSummary
    20  type NativeReportSummary struct {
    21  
    22  	// The complete percent of the scanning which value is between 0 and 100
    23  	// Example: 100
    24  	CompletePercent int64 `json:"complete_percent,omitempty"`
    25  
    26  	// The seconds spent for generating the report
    27  	// Example: 300
    28  	Duration int64 `json:"duration,omitempty"`
    29  
    30  	// The end time of the scan process that generating report
    31  	// Example: 2006-01-02T15:04:05Z
    32  	// Format: date-time
    33  	EndTime strfmt.DateTime `json:"end_time,omitempty"`
    34  
    35  	// id of the native scan report
    36  	// Example: 5f62c830-f996-11e9-957f-0242c0a89008
    37  	ReportID string `json:"report_id,omitempty"`
    38  
    39  	// The status of the report generating process
    40  	// Example: Success
    41  	ScanStatus string `json:"scan_status,omitempty"`
    42  
    43  	// scanner
    44  	Scanner *Scanner `json:"scanner,omitempty"`
    45  
    46  	// The overall severity
    47  	// Example: High
    48  	Severity string `json:"severity,omitempty"`
    49  
    50  	// The start time of the scan process that generating report
    51  	// Example: 2006-01-02T14:04:05Z
    52  	// Format: date-time
    53  	StartTime strfmt.DateTime `json:"start_time,omitempty"`
    54  
    55  	// summary
    56  	Summary *VulnerabilitySummary `json:"summary,omitempty"`
    57  }
    58  
    59  // Validate validates this native report summary
    60  func (m *NativeReportSummary) Validate(formats strfmt.Registry) error {
    61  	var res []error
    62  
    63  	if err := m.validateEndTime(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if err := m.validateScanner(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if err := m.validateStartTime(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validateSummary(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if len(res) > 0 {
    80  		return errors.CompositeValidationError(res...)
    81  	}
    82  	return nil
    83  }
    84  
    85  func (m *NativeReportSummary) validateEndTime(formats strfmt.Registry) error {
    86  	if swag.IsZero(m.EndTime) { // not required
    87  		return nil
    88  	}
    89  
    90  	if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil {
    91  		return err
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  func (m *NativeReportSummary) validateScanner(formats strfmt.Registry) error {
    98  	if swag.IsZero(m.Scanner) { // not required
    99  		return nil
   100  	}
   101  
   102  	if m.Scanner != nil {
   103  		if err := m.Scanner.Validate(formats); err != nil {
   104  			if ve, ok := err.(*errors.Validation); ok {
   105  				return ve.ValidateName("scanner")
   106  			} else if ce, ok := err.(*errors.CompositeError); ok {
   107  				return ce.ValidateName("scanner")
   108  			}
   109  			return err
   110  		}
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  func (m *NativeReportSummary) validateStartTime(formats strfmt.Registry) error {
   117  	if swag.IsZero(m.StartTime) { // not required
   118  		return nil
   119  	}
   120  
   121  	if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil {
   122  		return err
   123  	}
   124  
   125  	return nil
   126  }
   127  
   128  func (m *NativeReportSummary) validateSummary(formats strfmt.Registry) error {
   129  	if swag.IsZero(m.Summary) { // not required
   130  		return nil
   131  	}
   132  
   133  	if m.Summary != nil {
   134  		if err := m.Summary.Validate(formats); err != nil {
   135  			if ve, ok := err.(*errors.Validation); ok {
   136  				return ve.ValidateName("summary")
   137  			} else if ce, ok := err.(*errors.CompositeError); ok {
   138  				return ce.ValidateName("summary")
   139  			}
   140  			return err
   141  		}
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  // ContextValidate validate this native report summary based on the context it is used
   148  func (m *NativeReportSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   149  	var res []error
   150  
   151  	if err := m.contextValidateScanner(ctx, formats); err != nil {
   152  		res = append(res, err)
   153  	}
   154  
   155  	if err := m.contextValidateSummary(ctx, formats); err != nil {
   156  		res = append(res, err)
   157  	}
   158  
   159  	if len(res) > 0 {
   160  		return errors.CompositeValidationError(res...)
   161  	}
   162  	return nil
   163  }
   164  
   165  func (m *NativeReportSummary) contextValidateScanner(ctx context.Context, formats strfmt.Registry) error {
   166  
   167  	if m.Scanner != nil {
   168  		if err := m.Scanner.ContextValidate(ctx, formats); err != nil {
   169  			if ve, ok := err.(*errors.Validation); ok {
   170  				return ve.ValidateName("scanner")
   171  			} else if ce, ok := err.(*errors.CompositeError); ok {
   172  				return ce.ValidateName("scanner")
   173  			}
   174  			return err
   175  		}
   176  	}
   177  
   178  	return nil
   179  }
   180  
   181  func (m *NativeReportSummary) contextValidateSummary(ctx context.Context, formats strfmt.Registry) error {
   182  
   183  	if m.Summary != nil {
   184  		if err := m.Summary.ContextValidate(ctx, formats); err != nil {
   185  			if ve, ok := err.(*errors.Validation); ok {
   186  				return ve.ValidateName("summary")
   187  			} else if ce, ok := err.(*errors.CompositeError); ok {
   188  				return ce.ValidateName("summary")
   189  			}
   190  			return err
   191  		}
   192  	}
   193  
   194  	return nil
   195  }
   196  
   197  // MarshalBinary interface implementation
   198  func (m *NativeReportSummary) MarshalBinary() ([]byte, error) {
   199  	if m == nil {
   200  		return nil, nil
   201  	}
   202  	return swag.WriteJSON(m)
   203  }
   204  
   205  // UnmarshalBinary interface implementation
   206  func (m *NativeReportSummary) UnmarshalBinary(b []byte) error {
   207  	var res NativeReportSummary
   208  	if err := swag.ReadJSON(b, &res); err != nil {
   209  		return err
   210  	}
   211  	*m = res
   212  	return nil
   213  }