github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/status.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package 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  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // Status status
    19  // swagger:model Status
    20  type Status struct {
    21  
    22  	// difficulty
    23  	// Required: true
    24  	Difficulty *uint64 `json:"difficulty"`
    25  
    26  	// genesis key block hash
    27  	// Required: true
    28  	GenesisKeyBlockHash *string `json:"genesis_key_block_hash"`
    29  
    30  	// listening
    31  	// Required: true
    32  	Listening *bool `json:"listening"`
    33  
    34  	// network id
    35  	// Required: true
    36  	NetworkID *string `json:"network_id"`
    37  
    38  	// node revision
    39  	// Required: true
    40  	NodeRevision *string `json:"node_revision"`
    41  
    42  	// node version
    43  	// Required: true
    44  	NodeVersion *string `json:"node_version"`
    45  
    46  	// peer count
    47  	// Required: true
    48  	PeerCount *uint32 `json:"peer_count"`
    49  
    50  	// pending transactions count
    51  	// Required: true
    52  	PendingTransactionsCount *uint32 `json:"pending_transactions_count"`
    53  
    54  	// protocols
    55  	// Required: true
    56  	Protocols []*Protocol `json:"protocols"`
    57  
    58  	// solutions
    59  	// Required: true
    60  	Solutions *uint64 `json:"solutions"`
    61  
    62  	// sync progress
    63  	// Maximum: 100
    64  	// Minimum: 0
    65  	SyncProgress *float32 `json:"sync_progress,omitempty"`
    66  
    67  	// syncing
    68  	// Required: true
    69  	Syncing *bool `json:"syncing"`
    70  }
    71  
    72  // Validate validates this status
    73  func (m *Status) Validate(formats strfmt.Registry) error {
    74  	var res []error
    75  
    76  	if err := m.validateDifficulty(formats); err != nil {
    77  		res = append(res, err)
    78  	}
    79  
    80  	if err := m.validateGenesisKeyBlockHash(formats); err != nil {
    81  		res = append(res, err)
    82  	}
    83  
    84  	if err := m.validateListening(formats); err != nil {
    85  		res = append(res, err)
    86  	}
    87  
    88  	if err := m.validateNetworkID(formats); err != nil {
    89  		res = append(res, err)
    90  	}
    91  
    92  	if err := m.validateNodeRevision(formats); err != nil {
    93  		res = append(res, err)
    94  	}
    95  
    96  	if err := m.validateNodeVersion(formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	if err := m.validatePeerCount(formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if err := m.validatePendingTransactionsCount(formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	if err := m.validateProtocols(formats); err != nil {
   109  		res = append(res, err)
   110  	}
   111  
   112  	if err := m.validateSolutions(formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.validateSyncProgress(formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.validateSyncing(formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if len(res) > 0 {
   125  		return errors.CompositeValidationError(res...)
   126  	}
   127  	return nil
   128  }
   129  
   130  func (m *Status) validateDifficulty(formats strfmt.Registry) error {
   131  
   132  	if err := validate.Required("difficulty", "body", m.Difficulty); err != nil {
   133  		return err
   134  	}
   135  
   136  	return nil
   137  }
   138  
   139  func (m *Status) validateGenesisKeyBlockHash(formats strfmt.Registry) error {
   140  
   141  	if err := validate.Required("genesis_key_block_hash", "body", m.GenesisKeyBlockHash); err != nil {
   142  		return err
   143  	}
   144  
   145  	return nil
   146  }
   147  
   148  func (m *Status) validateListening(formats strfmt.Registry) error {
   149  
   150  	if err := validate.Required("listening", "body", m.Listening); err != nil {
   151  		return err
   152  	}
   153  
   154  	return nil
   155  }
   156  
   157  func (m *Status) validateNetworkID(formats strfmt.Registry) error {
   158  
   159  	if err := validate.Required("network_id", "body", m.NetworkID); err != nil {
   160  		return err
   161  	}
   162  
   163  	return nil
   164  }
   165  
   166  func (m *Status) validateNodeRevision(formats strfmt.Registry) error {
   167  
   168  	if err := validate.Required("node_revision", "body", m.NodeRevision); err != nil {
   169  		return err
   170  	}
   171  
   172  	return nil
   173  }
   174  
   175  func (m *Status) validateNodeVersion(formats strfmt.Registry) error {
   176  
   177  	if err := validate.Required("node_version", "body", m.NodeVersion); err != nil {
   178  		return err
   179  	}
   180  
   181  	return nil
   182  }
   183  
   184  func (m *Status) validatePeerCount(formats strfmt.Registry) error {
   185  
   186  	if err := validate.Required("peer_count", "body", m.PeerCount); err != nil {
   187  		return err
   188  	}
   189  
   190  	return nil
   191  }
   192  
   193  func (m *Status) validatePendingTransactionsCount(formats strfmt.Registry) error {
   194  
   195  	if err := validate.Required("pending_transactions_count", "body", m.PendingTransactionsCount); err != nil {
   196  		return err
   197  	}
   198  
   199  	return nil
   200  }
   201  
   202  func (m *Status) validateProtocols(formats strfmt.Registry) error {
   203  
   204  	if err := validate.Required("protocols", "body", m.Protocols); err != nil {
   205  		return err
   206  	}
   207  
   208  	for i := 0; i < len(m.Protocols); i++ {
   209  		if swag.IsZero(m.Protocols[i]) { // not required
   210  			continue
   211  		}
   212  
   213  		if m.Protocols[i] != nil {
   214  			if err := m.Protocols[i].Validate(formats); err != nil {
   215  				if ve, ok := err.(*errors.Validation); ok {
   216  					return ve.ValidateName("protocols" + "." + strconv.Itoa(i))
   217  				}
   218  				return err
   219  			}
   220  		}
   221  
   222  	}
   223  
   224  	return nil
   225  }
   226  
   227  func (m *Status) validateSolutions(formats strfmt.Registry) error {
   228  
   229  	if err := validate.Required("solutions", "body", m.Solutions); err != nil {
   230  		return err
   231  	}
   232  
   233  	return nil
   234  }
   235  
   236  func (m *Status) validateSyncProgress(formats strfmt.Registry) error {
   237  
   238  	if swag.IsZero(m.SyncProgress) { // not required
   239  		return nil
   240  	}
   241  
   242  	if err := validate.Minimum("sync_progress", "body", float64(*m.SyncProgress), 0, false); err != nil {
   243  		return err
   244  	}
   245  
   246  	if err := validate.Maximum("sync_progress", "body", float64(*m.SyncProgress), 100, false); err != nil {
   247  		return err
   248  	}
   249  
   250  	return nil
   251  }
   252  
   253  func (m *Status) validateSyncing(formats strfmt.Registry) error {
   254  
   255  	if err := validate.Required("syncing", "body", m.Syncing); err != nil {
   256  		return err
   257  	}
   258  
   259  	return nil
   260  }
   261  
   262  // MarshalBinary interface implementation
   263  func (m *Status) MarshalBinary() ([]byte, error) {
   264  	if m == nil {
   265  		return nil, nil
   266  	}
   267  	return swag.WriteJSON(m)
   268  }
   269  
   270  // UnmarshalBinary interface implementation
   271  func (m *Status) UnmarshalBinary(b []byte) error {
   272  	var res Status
   273  	if err := swag.ReadJSON(b, &res); err != nil {
   274  		return err
   275  	}
   276  	*m = res
   277  	return nil
   278  }