github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/kernel.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  )
    15  
    16  // Kernel Kernel
    17  //
    18  // The full kernel data model
    19  //
    20  // swagger:model kernel
    21  type Kernel struct {
    22  	KernelAllOf0
    23  
    24  	KernelCore
    25  }
    26  
    27  // UnmarshalJSON unmarshals this object from a JSON structure
    28  func (m *Kernel) UnmarshalJSON(raw []byte) error {
    29  	// AO0
    30  	var aO0 KernelAllOf0
    31  	if err := swag.ReadJSON(raw, &aO0); err != nil {
    32  		return err
    33  	}
    34  	m.KernelAllOf0 = aO0
    35  
    36  	// AO1
    37  	var aO1 KernelCore
    38  	if err := swag.ReadJSON(raw, &aO1); err != nil {
    39  		return err
    40  	}
    41  	m.KernelCore = aO1
    42  
    43  	return nil
    44  }
    45  
    46  // MarshalJSON marshals this object to a JSON structure
    47  func (m Kernel) MarshalJSON() ([]byte, error) {
    48  	_parts := make([][]byte, 0, 2)
    49  
    50  	aO0, err := swag.WriteJSON(m.KernelAllOf0)
    51  	if err != nil {
    52  		return nil, err
    53  	}
    54  	_parts = append(_parts, aO0)
    55  
    56  	aO1, err := swag.WriteJSON(m.KernelCore)
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  	_parts = append(_parts, aO1)
    61  	return swag.ConcatJSON(_parts...), nil
    62  }
    63  
    64  // Validate validates this kernel
    65  func (m *Kernel) Validate(formats strfmt.Registry) error {
    66  	var res []error
    67  
    68  	// validation for a type composition with KernelAllOf0
    69  	if err := m.KernelAllOf0.Validate(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  	// validation for a type composition with KernelCore
    73  	if err := m.KernelCore.Validate(formats); err != nil {
    74  		res = append(res, err)
    75  	}
    76  
    77  	if len(res) > 0 {
    78  		return errors.CompositeValidationError(res...)
    79  	}
    80  	return nil
    81  }
    82  
    83  // ContextValidate validate this kernel based on the context it is used
    84  func (m *Kernel) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    85  	var res []error
    86  
    87  	// validation for a type composition with KernelAllOf0
    88  	if err := m.KernelAllOf0.ContextValidate(ctx, formats); err != nil {
    89  		res = append(res, err)
    90  	}
    91  	// validation for a type composition with KernelCore
    92  	if err := m.KernelCore.ContextValidate(ctx, formats); err != nil {
    93  		res = append(res, err)
    94  	}
    95  
    96  	if len(res) > 0 {
    97  		return errors.CompositeValidationError(res...)
    98  	}
    99  	return nil
   100  }
   101  
   102  // MarshalBinary interface implementation
   103  func (m *Kernel) MarshalBinary() ([]byte, error) {
   104  	if m == nil {
   105  		return nil, nil
   106  	}
   107  	return swag.WriteJSON(m)
   108  }
   109  
   110  // UnmarshalBinary interface implementation
   111  func (m *Kernel) UnmarshalBinary(b []byte) error {
   112  	var res Kernel
   113  	if err := swag.ReadJSON(b, &res); err != nil {
   114  		return err
   115  	}
   116  	*m = res
   117  	return nil
   118  }