github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/solution_recipe.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  
    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  // SolutionRecipe SolverRecipe
    18  //
    19  // A recipe with a URL, created by a solver, containing all required information to build for a single platform
    20  //
    21  // swagger:model solutionRecipe
    22  type SolutionRecipe struct {
    23  
    24  	// links
    25  	// Required: true
    26  	Links *SelfLink `json:"links"`
    27  
    28  	// recipe
    29  	// Required: true
    30  	Recipe *Recipe `json:"recipe"`
    31  }
    32  
    33  // Validate validates this solution recipe
    34  func (m *SolutionRecipe) Validate(formats strfmt.Registry) error {
    35  	var res []error
    36  
    37  	if err := m.validateLinks(formats); err != nil {
    38  		res = append(res, err)
    39  	}
    40  
    41  	if err := m.validateRecipe(formats); err != nil {
    42  		res = append(res, err)
    43  	}
    44  
    45  	if len(res) > 0 {
    46  		return errors.CompositeValidationError(res...)
    47  	}
    48  	return nil
    49  }
    50  
    51  func (m *SolutionRecipe) validateLinks(formats strfmt.Registry) error {
    52  
    53  	if err := validate.Required("links", "body", m.Links); err != nil {
    54  		return err
    55  	}
    56  
    57  	if m.Links != nil {
    58  		if err := m.Links.Validate(formats); err != nil {
    59  			if ve, ok := err.(*errors.Validation); ok {
    60  				return ve.ValidateName("links")
    61  			}
    62  			return err
    63  		}
    64  	}
    65  
    66  	return nil
    67  }
    68  
    69  func (m *SolutionRecipe) validateRecipe(formats strfmt.Registry) error {
    70  
    71  	if err := validate.Required("recipe", "body", m.Recipe); err != nil {
    72  		return err
    73  	}
    74  
    75  	if m.Recipe != nil {
    76  		if err := m.Recipe.Validate(formats); err != nil {
    77  			if ve, ok := err.(*errors.Validation); ok {
    78  				return ve.ValidateName("recipe")
    79  			}
    80  			return err
    81  		}
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  // ContextValidate validate this solution recipe based on the context it is used
    88  func (m *SolutionRecipe) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    89  	var res []error
    90  
    91  	if err := m.contextValidateLinks(ctx, formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.contextValidateRecipe(ctx, formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if len(res) > 0 {
   100  		return errors.CompositeValidationError(res...)
   101  	}
   102  	return nil
   103  }
   104  
   105  func (m *SolutionRecipe) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error {
   106  
   107  	if m.Links != nil {
   108  		if err := m.Links.ContextValidate(ctx, formats); err != nil {
   109  			if ve, ok := err.(*errors.Validation); ok {
   110  				return ve.ValidateName("links")
   111  			}
   112  			return err
   113  		}
   114  	}
   115  
   116  	return nil
   117  }
   118  
   119  func (m *SolutionRecipe) contextValidateRecipe(ctx context.Context, formats strfmt.Registry) error {
   120  
   121  	if m.Recipe != nil {
   122  		if err := m.Recipe.ContextValidate(ctx, formats); err != nil {
   123  			if ve, ok := err.(*errors.Validation); ok {
   124  				return ve.ValidateName("recipe")
   125  			}
   126  			return err
   127  		}
   128  	}
   129  
   130  	return nil
   131  }
   132  
   133  // MarshalBinary interface implementation
   134  func (m *SolutionRecipe) MarshalBinary() ([]byte, error) {
   135  	if m == nil {
   136  		return nil, nil
   137  	}
   138  	return swag.WriteJSON(m)
   139  }
   140  
   141  // UnmarshalBinary interface implementation
   142  func (m *SolutionRecipe) UnmarshalBinary(b []byte) error {
   143  	var res SolutionRecipe
   144  	if err := swag.ReadJSON(b, &res); err != nil {
   145  		return err
   146  	}
   147  	*m = res
   148  	return nil
   149  }