github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/solver_incompatibility.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package inventory_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  	"encoding/json"
    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  // SolverIncompatibility Solver Incompatibility
    19  //
    20  // A requirement, transitive dependency or platform that is part of a solver error
    21  //
    22  // swagger:model solverIncompatibility
    23  type SolverIncompatibility struct {
    24  
    25  	// The name of the dependency or requirement feature
    26  	Feature string `json:"feature,omitempty"`
    27  
    28  	// The name of the dependency or requirement namespace
    29  	Namespace string `json:"namespace,omitempty"`
    30  
    31  	// The id of the platform
    32  	// Format: uuid
    33  	PlatformID strfmt.UUID `json:"platform_id,omitempty"`
    34  
    35  	// The name of the platform's kernel
    36  	PlatformKernel string `json:"platform_kernel,omitempty"`
    37  
    38  	// The type of this incompatibility
    39  	// Required: true
    40  	// Enum: [dependency platform requirement]
    41  	Type *string `json:"type"`
    42  }
    43  
    44  // Validate validates this solver incompatibility
    45  func (m *SolverIncompatibility) Validate(formats strfmt.Registry) error {
    46  	var res []error
    47  
    48  	if err := m.validatePlatformID(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if err := m.validateType(formats); err != nil {
    53  		res = append(res, err)
    54  	}
    55  
    56  	if len(res) > 0 {
    57  		return errors.CompositeValidationError(res...)
    58  	}
    59  	return nil
    60  }
    61  
    62  func (m *SolverIncompatibility) validatePlatformID(formats strfmt.Registry) error {
    63  	if swag.IsZero(m.PlatformID) { // not required
    64  		return nil
    65  	}
    66  
    67  	if err := validate.FormatOf("platform_id", "body", "uuid", m.PlatformID.String(), formats); err != nil {
    68  		return err
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  var solverIncompatibilityTypeTypePropEnum []interface{}
    75  
    76  func init() {
    77  	var res []string
    78  	if err := json.Unmarshal([]byte(`["dependency","platform","requirement"]`), &res); err != nil {
    79  		panic(err)
    80  	}
    81  	for _, v := range res {
    82  		solverIncompatibilityTypeTypePropEnum = append(solverIncompatibilityTypeTypePropEnum, v)
    83  	}
    84  }
    85  
    86  const (
    87  
    88  	// SolverIncompatibilityTypeDependency captures enum value "dependency"
    89  	SolverIncompatibilityTypeDependency string = "dependency"
    90  
    91  	// SolverIncompatibilityTypePlatform captures enum value "platform"
    92  	SolverIncompatibilityTypePlatform string = "platform"
    93  
    94  	// SolverIncompatibilityTypeRequirement captures enum value "requirement"
    95  	SolverIncompatibilityTypeRequirement string = "requirement"
    96  )
    97  
    98  // prop value enum
    99  func (m *SolverIncompatibility) validateTypeEnum(path, location string, value string) error {
   100  	if err := validate.EnumCase(path, location, value, solverIncompatibilityTypeTypePropEnum, true); err != nil {
   101  		return err
   102  	}
   103  	return nil
   104  }
   105  
   106  func (m *SolverIncompatibility) validateType(formats strfmt.Registry) error {
   107  
   108  	if err := validate.Required("type", "body", m.Type); err != nil {
   109  		return err
   110  	}
   111  
   112  	// value enum
   113  	if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
   114  		return err
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  // ContextValidate validates this solver incompatibility based on context it is used
   121  func (m *SolverIncompatibility) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   122  	return nil
   123  }
   124  
   125  // MarshalBinary interface implementation
   126  func (m *SolverIncompatibility) MarshalBinary() ([]byte, error) {
   127  	if m == nil {
   128  		return nil, nil
   129  	}
   130  	return swag.WriteJSON(m)
   131  }
   132  
   133  // UnmarshalBinary interface implementation
   134  func (m *SolverIncompatibility) UnmarshalBinary(b []byte) error {
   135  	var res SolverIncompatibility
   136  	if err := swag.ReadJSON(b, &res); err != nil {
   137  		return err
   138  	}
   139  	*m = res
   140  	return nil
   141  }