github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/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 EncodedHash `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 := m.Difficulty.Validate(formats); err != nil {
   133  		if ve, ok := err.(*errors.Validation); ok {
   134  			return ve.ValidateName("difficulty")
   135  		}
   136  		return err
   137  	}
   138  
   139  	return nil
   140  }
   141  
   142  func (m *Status) validateGenesisKeyBlockHash(formats strfmt.Registry) error {
   143  
   144  	if err := m.GenesisKeyBlockHash.Validate(formats); err != nil {
   145  		if ve, ok := err.(*errors.Validation); ok {
   146  			return ve.ValidateName("genesis_key_block_hash")
   147  		}
   148  		return err
   149  	}
   150  
   151  	return nil
   152  }
   153  
   154  func (m *Status) validateListening(formats strfmt.Registry) error {
   155  
   156  	if err := validate.Required("listening", "body", m.Listening); err != nil {
   157  		return err
   158  	}
   159  
   160  	return nil
   161  }
   162  
   163  func (m *Status) validateNetworkID(formats strfmt.Registry) error {
   164  
   165  	if err := validate.Required("network_id", "body", m.NetworkID); err != nil {
   166  		return err
   167  	}
   168  
   169  	return nil
   170  }
   171  
   172  func (m *Status) validateNodeRevision(formats strfmt.Registry) error {
   173  
   174  	if err := validate.Required("node_revision", "body", m.NodeRevision); err != nil {
   175  		return err
   176  	}
   177  
   178  	return nil
   179  }
   180  
   181  func (m *Status) validateNodeVersion(formats strfmt.Registry) error {
   182  
   183  	if err := validate.Required("node_version", "body", m.NodeVersion); err != nil {
   184  		return err
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  func (m *Status) validatePeerCount(formats strfmt.Registry) error {
   191  
   192  	if err := m.PeerCount.Validate(formats); err != nil {
   193  		if ve, ok := err.(*errors.Validation); ok {
   194  			return ve.ValidateName("peer_count")
   195  		}
   196  		return err
   197  	}
   198  
   199  	return nil
   200  }
   201  
   202  func (m *Status) validatePendingTransactionsCount(formats strfmt.Registry) error {
   203  
   204  	if err := m.PendingTransactionsCount.Validate(formats); err != nil {
   205  		if ve, ok := err.(*errors.Validation); ok {
   206  			return ve.ValidateName("pending_transactions_count")
   207  		}
   208  		return err
   209  	}
   210  
   211  	return nil
   212  }
   213  
   214  func (m *Status) validateProtocols(formats strfmt.Registry) error {
   215  
   216  	if err := validate.Required("protocols", "body", m.Protocols); err != nil {
   217  		return err
   218  	}
   219  
   220  	for i := 0; i < len(m.Protocols); i++ {
   221  		if swag.IsZero(m.Protocols[i]) { // not required
   222  			continue
   223  		}
   224  
   225  		if m.Protocols[i] != nil {
   226  			if err := m.Protocols[i].Validate(formats); err != nil {
   227  				if ve, ok := err.(*errors.Validation); ok {
   228  					return ve.ValidateName("protocols" + "." + strconv.Itoa(i))
   229  				}
   230  				return err
   231  			}
   232  		}
   233  
   234  	}
   235  
   236  	return nil
   237  }
   238  
   239  func (m *Status) validateSolutions(formats strfmt.Registry) error {
   240  
   241  	if err := m.Solutions.Validate(formats); err != nil {
   242  		if ve, ok := err.(*errors.Validation); ok {
   243  			return ve.ValidateName("solutions")
   244  		}
   245  		return err
   246  	}
   247  
   248  	return nil
   249  }
   250  
   251  func (m *Status) validateSyncProgress(formats strfmt.Registry) error {
   252  
   253  	if swag.IsZero(m.SyncProgress) { // not required
   254  		return nil
   255  	}
   256  
   257  	if err := validate.Minimum("sync_progress", "body", float64(*m.SyncProgress), 0, false); err != nil {
   258  		return err
   259  	}
   260  
   261  	if err := validate.Maximum("sync_progress", "body", float64(*m.SyncProgress), 100, false); err != nil {
   262  		return err
   263  	}
   264  
   265  	return nil
   266  }
   267  
   268  func (m *Status) validateSyncing(formats strfmt.Registry) error {
   269  
   270  	if err := validate.Required("syncing", "body", m.Syncing); err != nil {
   271  		return err
   272  	}
   273  
   274  	return nil
   275  }
   276  
   277  // MarshalBinary interface implementation
   278  func (m *Status) MarshalBinary() ([]byte, error) {
   279  	if m == nil {
   280  		return nil, nil
   281  	}
   282  	return swag.WriteJSON(m)
   283  }
   284  
   285  // UnmarshalBinary interface implementation
   286  func (m *Status) UnmarshalBinary(b []byte) error {
   287  	var res Status
   288  	if err := swag.ReadJSON(b, &res); err != nil {
   289  		return err
   290  	}
   291  	*m = res
   292  	return nil
   293  }