github.com/cilium/cilium@v1.16.2/api/v1/models/dns_lookup.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package models
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"context"
    13  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/strfmt"
    16  	"github.com/go-openapi/swag"
    17  	"github.com/go-openapi/validate"
    18  )
    19  
    20  // DNSLookup An IP -> DNS mapping, with metadata
    21  //
    22  // swagger:model DNSLookup
    23  type DNSLookup struct {
    24  
    25  	// The endpoint that made this lookup, or 0 for the agent itself.
    26  	EndpointID int64 `json:"endpoint-id,omitempty"`
    27  
    28  	// The absolute time when this data will expire in this cache
    29  	// Format: date-time
    30  	ExpirationTime strfmt.DateTime `json:"expiration-time,omitempty"`
    31  
    32  	// DNS name
    33  	Fqdn string `json:"fqdn,omitempty"`
    34  
    35  	// IP addresses returned in this lookup
    36  	Ips []string `json:"ips"`
    37  
    38  	// The absolute time when this data was received
    39  	// Format: date-time
    40  	LookupTime strfmt.DateTime `json:"lookup-time,omitempty"`
    41  
    42  	// The reason this FQDN IP association exists. Either a DNS lookup or an ongoing connection to an IP that was created by a DNS lookup.
    43  	Source string `json:"source,omitempty"`
    44  
    45  	// The TTL in the DNS response
    46  	TTL int64 `json:"ttl,omitempty"`
    47  }
    48  
    49  // Validate validates this DNS lookup
    50  func (m *DNSLookup) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateExpirationTime(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateLookupTime(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if len(res) > 0 {
    62  		return errors.CompositeValidationError(res...)
    63  	}
    64  	return nil
    65  }
    66  
    67  func (m *DNSLookup) validateExpirationTime(formats strfmt.Registry) error {
    68  	if swag.IsZero(m.ExpirationTime) { // not required
    69  		return nil
    70  	}
    71  
    72  	if err := validate.FormatOf("expiration-time", "body", "date-time", m.ExpirationTime.String(), formats); err != nil {
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  func (m *DNSLookup) validateLookupTime(formats strfmt.Registry) error {
    80  	if swag.IsZero(m.LookupTime) { // not required
    81  		return nil
    82  	}
    83  
    84  	if err := validate.FormatOf("lookup-time", "body", "date-time", m.LookupTime.String(), formats); err != nil {
    85  		return err
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  // ContextValidate validates this DNS lookup based on context it is used
    92  func (m *DNSLookup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    93  	return nil
    94  }
    95  
    96  // MarshalBinary interface implementation
    97  func (m *DNSLookup) MarshalBinary() ([]byte, error) {
    98  	if m == nil {
    99  		return nil, nil
   100  	}
   101  	return swag.WriteJSON(m)
   102  }
   103  
   104  // UnmarshalBinary interface implementation
   105  func (m *DNSLookup) UnmarshalBinary(b []byte) error {
   106  	var res DNSLookup
   107  	if err := swag.ReadJSON(b, &res); err != nil {
   108  		return err
   109  	}
   110  	*m = res
   111  	return nil
   112  }