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