github.com/digitalocean/go-netbox@v0.0.2/netbox/models/prefix_length.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright 2020 The go-netbox Authors.
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //   http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  //
    17  
    18  package models
    19  
    20  // This file was generated by the swagger tool.
    21  // Editing this file might prove futile when you re-run the swagger generate command
    22  
    23  import (
    24  	"context"
    25  
    26  	"github.com/go-openapi/errors"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  	"github.com/go-openapi/validate"
    30  )
    31  
    32  // PrefixLength prefix length
    33  //
    34  // swagger:model PrefixLength
    35  type PrefixLength struct {
    36  
    37  	// Prefix length
    38  	// Required: true
    39  	PrefixLength *int64 `json:"prefix_length"`
    40  }
    41  
    42  // Validate validates this prefix length
    43  func (m *PrefixLength) Validate(formats strfmt.Registry) error {
    44  	var res []error
    45  
    46  	if err := m.validatePrefixLength(formats); err != nil {
    47  		res = append(res, err)
    48  	}
    49  
    50  	if len(res) > 0 {
    51  		return errors.CompositeValidationError(res...)
    52  	}
    53  	return nil
    54  }
    55  
    56  func (m *PrefixLength) validatePrefixLength(formats strfmt.Registry) error {
    57  
    58  	if err := validate.Required("prefix_length", "body", m.PrefixLength); err != nil {
    59  		return err
    60  	}
    61  
    62  	return nil
    63  }
    64  
    65  // ContextValidate validates this prefix length based on context it is used
    66  func (m *PrefixLength) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    67  	return nil
    68  }
    69  
    70  // MarshalBinary interface implementation
    71  func (m *PrefixLength) MarshalBinary() ([]byte, error) {
    72  	if m == nil {
    73  		return nil, nil
    74  	}
    75  	return swag.WriteJSON(m)
    76  }
    77  
    78  // UnmarshalBinary interface implementation
    79  func (m *PrefixLength) UnmarshalBinary(b []byte) error {
    80  	var res PrefixLength
    81  	if err := swag.ReadJSON(b, &res); err != nil {
    82  		return err
    83  	}
    84  	*m = res
    85  	return nil
    86  }