github.com/digitalocean/go-netbox@v0.0.2/netbox/models/nested_v_r_f.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  // NestedVRF nested v r f
    33  //
    34  // swagger:model NestedVRF
    35  type NestedVRF struct {
    36  
    37  	// Display
    38  	// Read Only: true
    39  	Display string `json:"display,omitempty"`
    40  
    41  	// Display name
    42  	// Read Only: true
    43  	DisplayName string `json:"display_name,omitempty"`
    44  
    45  	// Id
    46  	// Read Only: true
    47  	ID int64 `json:"id,omitempty"`
    48  
    49  	// Name
    50  	// Required: true
    51  	// Max Length: 100
    52  	// Min Length: 1
    53  	Name *string `json:"name"`
    54  
    55  	// Prefix count
    56  	// Read Only: true
    57  	PrefixCount int64 `json:"prefix_count,omitempty"`
    58  
    59  	// Route distinguisher
    60  	//
    61  	// Unique route distinguisher (as defined in RFC 4364)
    62  	// Max Length: 21
    63  	Rd *string `json:"rd,omitempty"`
    64  
    65  	// Url
    66  	// Read Only: true
    67  	// Format: uri
    68  	URL strfmt.URI `json:"url,omitempty"`
    69  }
    70  
    71  // Validate validates this nested v r f
    72  func (m *NestedVRF) Validate(formats strfmt.Registry) error {
    73  	var res []error
    74  
    75  	if err := m.validateName(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateRd(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateURL(formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if len(res) > 0 {
    88  		return errors.CompositeValidationError(res...)
    89  	}
    90  	return nil
    91  }
    92  
    93  func (m *NestedVRF) validateName(formats strfmt.Registry) error {
    94  
    95  	if err := validate.Required("name", "body", m.Name); err != nil {
    96  		return err
    97  	}
    98  
    99  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   100  		return err
   101  	}
   102  
   103  	if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil {
   104  		return err
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  func (m *NestedVRF) validateRd(formats strfmt.Registry) error {
   111  	if swag.IsZero(m.Rd) { // not required
   112  		return nil
   113  	}
   114  
   115  	if err := validate.MaxLength("rd", "body", *m.Rd, 21); err != nil {
   116  		return err
   117  	}
   118  
   119  	return nil
   120  }
   121  
   122  func (m *NestedVRF) validateURL(formats strfmt.Registry) error {
   123  	if swag.IsZero(m.URL) { // not required
   124  		return nil
   125  	}
   126  
   127  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   128  		return err
   129  	}
   130  
   131  	return nil
   132  }
   133  
   134  // ContextValidate validate this nested v r f based on the context it is used
   135  func (m *NestedVRF) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   136  	var res []error
   137  
   138  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   139  		res = append(res, err)
   140  	}
   141  
   142  	if err := m.contextValidateDisplayName(ctx, formats); err != nil {
   143  		res = append(res, err)
   144  	}
   145  
   146  	if err := m.contextValidateID(ctx, formats); err != nil {
   147  		res = append(res, err)
   148  	}
   149  
   150  	if err := m.contextValidatePrefixCount(ctx, formats); err != nil {
   151  		res = append(res, err)
   152  	}
   153  
   154  	if err := m.contextValidateURL(ctx, formats); err != nil {
   155  		res = append(res, err)
   156  	}
   157  
   158  	if len(res) > 0 {
   159  		return errors.CompositeValidationError(res...)
   160  	}
   161  	return nil
   162  }
   163  
   164  func (m *NestedVRF) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   165  
   166  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   167  		return err
   168  	}
   169  
   170  	return nil
   171  }
   172  
   173  func (m *NestedVRF) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error {
   174  
   175  	if err := validate.ReadOnly(ctx, "display_name", "body", string(m.DisplayName)); err != nil {
   176  		return err
   177  	}
   178  
   179  	return nil
   180  }
   181  
   182  func (m *NestedVRF) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   183  
   184  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   185  		return err
   186  	}
   187  
   188  	return nil
   189  }
   190  
   191  func (m *NestedVRF) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error {
   192  
   193  	if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil {
   194  		return err
   195  	}
   196  
   197  	return nil
   198  }
   199  
   200  func (m *NestedVRF) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   201  
   202  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   203  		return err
   204  	}
   205  
   206  	return nil
   207  }
   208  
   209  // MarshalBinary interface implementation
   210  func (m *NestedVRF) MarshalBinary() ([]byte, error) {
   211  	if m == nil {
   212  		return nil, nil
   213  	}
   214  	return swag.WriteJSON(m)
   215  }
   216  
   217  // UnmarshalBinary interface implementation
   218  func (m *NestedVRF) UnmarshalBinary(b []byte) error {
   219  	var res NestedVRF
   220  	if err := swag.ReadJSON(b, &res); err != nil {
   221  		return err
   222  	}
   223  	*m = res
   224  	return nil
   225  }