github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/execution.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  // Execution execution
    17  //
    18  // swagger:model Execution
    19  type Execution struct {
    20  
    21  	// The end time of execution
    22  	EndTime string `json:"end_time,omitempty"`
    23  
    24  	// extra attrs
    25  	ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"`
    26  
    27  	// The ID of execution
    28  	ID int64 `json:"id,omitempty"`
    29  
    30  	// metrics
    31  	Metrics *Metrics `json:"metrics,omitempty"`
    32  
    33  	// The start time of execution
    34  	StartTime string `json:"start_time,omitempty"`
    35  
    36  	// The status of execution
    37  	Status string `json:"status,omitempty"`
    38  
    39  	// The status message of execution
    40  	StatusMessage string `json:"status_message,omitempty"`
    41  
    42  	// The trigger of execution
    43  	Trigger string `json:"trigger,omitempty"`
    44  
    45  	// The vendor id of execution
    46  	VendorID int64 `json:"vendor_id,omitempty"`
    47  
    48  	// The vendor type of execution
    49  	VendorType string `json:"vendor_type,omitempty"`
    50  }
    51  
    52  // Validate validates this execution
    53  func (m *Execution) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateExtraAttrs(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateMetrics(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if len(res) > 0 {
    65  		return errors.CompositeValidationError(res...)
    66  	}
    67  	return nil
    68  }
    69  
    70  func (m *Execution) validateExtraAttrs(formats strfmt.Registry) error {
    71  	if swag.IsZero(m.ExtraAttrs) { // not required
    72  		return nil
    73  	}
    74  
    75  	if m.ExtraAttrs != nil {
    76  		if err := m.ExtraAttrs.Validate(formats); err != nil {
    77  			if ve, ok := err.(*errors.Validation); ok {
    78  				return ve.ValidateName("extra_attrs")
    79  			} else if ce, ok := err.(*errors.CompositeError); ok {
    80  				return ce.ValidateName("extra_attrs")
    81  			}
    82  			return err
    83  		}
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  func (m *Execution) validateMetrics(formats strfmt.Registry) error {
    90  	if swag.IsZero(m.Metrics) { // not required
    91  		return nil
    92  	}
    93  
    94  	if m.Metrics != nil {
    95  		if err := m.Metrics.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("metrics")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("metrics")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  // ContextValidate validate this execution based on the context it is used
   109  func (m *Execution) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   110  	var res []error
   111  
   112  	if err := m.contextValidateExtraAttrs(ctx, formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.contextValidateMetrics(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if len(res) > 0 {
   121  		return errors.CompositeValidationError(res...)
   122  	}
   123  	return nil
   124  }
   125  
   126  func (m *Execution) contextValidateExtraAttrs(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if err := m.ExtraAttrs.ContextValidate(ctx, formats); err != nil {
   129  		if ve, ok := err.(*errors.Validation); ok {
   130  			return ve.ValidateName("extra_attrs")
   131  		} else if ce, ok := err.(*errors.CompositeError); ok {
   132  			return ce.ValidateName("extra_attrs")
   133  		}
   134  		return err
   135  	}
   136  
   137  	return nil
   138  }
   139  
   140  func (m *Execution) contextValidateMetrics(ctx context.Context, formats strfmt.Registry) error {
   141  
   142  	if m.Metrics != nil {
   143  		if err := m.Metrics.ContextValidate(ctx, formats); err != nil {
   144  			if ve, ok := err.(*errors.Validation); ok {
   145  				return ve.ValidateName("metrics")
   146  			} else if ce, ok := err.(*errors.CompositeError); ok {
   147  				return ce.ValidateName("metrics")
   148  			}
   149  			return err
   150  		}
   151  	}
   152  
   153  	return nil
   154  }
   155  
   156  // MarshalBinary interface implementation
   157  func (m *Execution) MarshalBinary() ([]byte, error) {
   158  	if m == nil {
   159  		return nil, nil
   160  	}
   161  	return swag.WriteJSON(m)
   162  }
   163  
   164  // UnmarshalBinary interface implementation
   165  func (m *Execution) UnmarshalBinary(b []byte) error {
   166  	var res Execution
   167  	if err := swag.ReadJSON(b, &res); err != nil {
   168  		return err
   169  	}
   170  	*m = res
   171  	return nil
   172  }