github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/paging_links.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  // PagingLinks Paging Links
    18  //
    19  // Links for a model that include links for paging data
    20  //
    21  // swagger:model pagingLinks
    22  type PagingLinks struct {
    23  
    24  	// The URI of the first page
    25  	// Required: true
    26  	// Format: uri
    27  	First *strfmt.URI `json:"first"`
    28  
    29  	// The URI of last page
    30  	// Required: true
    31  	// Format: uri
    32  	Last *strfmt.URI `json:"last"`
    33  
    34  	// The URI of the next page
    35  	// Format: uri
    36  	Next strfmt.URI `json:"next,omitempty"`
    37  
    38  	// The URI of the previous page
    39  	// Format: uri
    40  	Previous strfmt.URI `json:"previous,omitempty"`
    41  
    42  	// The URI of this page
    43  	// Required: true
    44  	// Format: uri
    45  	Self *strfmt.URI `json:"self"`
    46  }
    47  
    48  // Validate validates this paging links
    49  func (m *PagingLinks) Validate(formats strfmt.Registry) error {
    50  	var res []error
    51  
    52  	if err := m.validateFirst(formats); err != nil {
    53  		res = append(res, err)
    54  	}
    55  
    56  	if err := m.validateLast(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateNext(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if err := m.validatePrevious(formats); err != nil {
    65  		res = append(res, err)
    66  	}
    67  
    68  	if err := m.validateSelf(formats); err != nil {
    69  		res = append(res, err)
    70  	}
    71  
    72  	if len(res) > 0 {
    73  		return errors.CompositeValidationError(res...)
    74  	}
    75  	return nil
    76  }
    77  
    78  func (m *PagingLinks) validateFirst(formats strfmt.Registry) error {
    79  
    80  	if err := validate.Required("first", "body", m.First); err != nil {
    81  		return err
    82  	}
    83  
    84  	if err := validate.FormatOf("first", "body", "uri", m.First.String(), formats); err != nil {
    85  		return err
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  func (m *PagingLinks) validateLast(formats strfmt.Registry) error {
    92  
    93  	if err := validate.Required("last", "body", m.Last); err != nil {
    94  		return err
    95  	}
    96  
    97  	if err := validate.FormatOf("last", "body", "uri", m.Last.String(), formats); err != nil {
    98  		return err
    99  	}
   100  
   101  	return nil
   102  }
   103  
   104  func (m *PagingLinks) validateNext(formats strfmt.Registry) error {
   105  	if swag.IsZero(m.Next) { // not required
   106  		return nil
   107  	}
   108  
   109  	if err := validate.FormatOf("next", "body", "uri", m.Next.String(), formats); err != nil {
   110  		return err
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  func (m *PagingLinks) validatePrevious(formats strfmt.Registry) error {
   117  	if swag.IsZero(m.Previous) { // not required
   118  		return nil
   119  	}
   120  
   121  	if err := validate.FormatOf("previous", "body", "uri", m.Previous.String(), formats); err != nil {
   122  		return err
   123  	}
   124  
   125  	return nil
   126  }
   127  
   128  func (m *PagingLinks) validateSelf(formats strfmt.Registry) error {
   129  
   130  	if err := validate.Required("self", "body", m.Self); err != nil {
   131  		return err
   132  	}
   133  
   134  	if err := validate.FormatOf("self", "body", "uri", m.Self.String(), formats); err != nil {
   135  		return err
   136  	}
   137  
   138  	return nil
   139  }
   140  
   141  // ContextValidate validates this paging links based on context it is used
   142  func (m *PagingLinks) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   143  	return nil
   144  }
   145  
   146  // MarshalBinary interface implementation
   147  func (m *PagingLinks) MarshalBinary() ([]byte, error) {
   148  	if m == nil {
   149  		return nil, nil
   150  	}
   151  	return swag.WriteJSON(m)
   152  }
   153  
   154  // UnmarshalBinary interface implementation
   155  func (m *PagingLinks) UnmarshalBinary(b []byte) error {
   156  	var res PagingLinks
   157  	if err := swag.ReadJSON(b, &res); err != nil {
   158  		return err
   159  	}
   160  	*m = res
   161  	return nil
   162  }