github.com/digitalocean/go-netbox@v0.0.2/netbox/models/device_bay_template.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  // DeviceBayTemplate device bay template
    33  //
    34  // swagger:model DeviceBayTemplate
    35  type DeviceBayTemplate struct {
    36  
    37  	// Created
    38  	// Read Only: true
    39  	// Format: date
    40  	Created strfmt.Date `json:"created,omitempty"`
    41  
    42  	// Description
    43  	// Max Length: 200
    44  	Description string `json:"description,omitempty"`
    45  
    46  	// device type
    47  	// Required: true
    48  	DeviceType *NestedDeviceType `json:"device_type"`
    49  
    50  	// Display
    51  	// Read Only: true
    52  	Display string `json:"display,omitempty"`
    53  
    54  	// Id
    55  	// Read Only: true
    56  	ID int64 `json:"id,omitempty"`
    57  
    58  	// Label
    59  	//
    60  	// Physical label
    61  	// Max Length: 64
    62  	Label string `json:"label,omitempty"`
    63  
    64  	// Last updated
    65  	// Read Only: true
    66  	// Format: date-time
    67  	LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
    68  
    69  	// Name
    70  	// Required: true
    71  	// Max Length: 64
    72  	// Min Length: 1
    73  	Name *string `json:"name"`
    74  
    75  	// Url
    76  	// Read Only: true
    77  	// Format: uri
    78  	URL strfmt.URI `json:"url,omitempty"`
    79  }
    80  
    81  // Validate validates this device bay template
    82  func (m *DeviceBayTemplate) Validate(formats strfmt.Registry) error {
    83  	var res []error
    84  
    85  	if err := m.validateCreated(formats); err != nil {
    86  		res = append(res, err)
    87  	}
    88  
    89  	if err := m.validateDescription(formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if err := m.validateDeviceType(formats); err != nil {
    94  		res = append(res, err)
    95  	}
    96  
    97  	if err := m.validateLabel(formats); err != nil {
    98  		res = append(res, err)
    99  	}
   100  
   101  	if err := m.validateLastUpdated(formats); err != nil {
   102  		res = append(res, err)
   103  	}
   104  
   105  	if err := m.validateName(formats); err != nil {
   106  		res = append(res, err)
   107  	}
   108  
   109  	if err := m.validateURL(formats); err != nil {
   110  		res = append(res, err)
   111  	}
   112  
   113  	if len(res) > 0 {
   114  		return errors.CompositeValidationError(res...)
   115  	}
   116  	return nil
   117  }
   118  
   119  func (m *DeviceBayTemplate) validateCreated(formats strfmt.Registry) error {
   120  	if swag.IsZero(m.Created) { // not required
   121  		return nil
   122  	}
   123  
   124  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   125  		return err
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  func (m *DeviceBayTemplate) validateDescription(formats strfmt.Registry) error {
   132  	if swag.IsZero(m.Description) { // not required
   133  		return nil
   134  	}
   135  
   136  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   137  		return err
   138  	}
   139  
   140  	return nil
   141  }
   142  
   143  func (m *DeviceBayTemplate) validateDeviceType(formats strfmt.Registry) error {
   144  
   145  	if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
   146  		return err
   147  	}
   148  
   149  	if m.DeviceType != nil {
   150  		if err := m.DeviceType.Validate(formats); err != nil {
   151  			if ve, ok := err.(*errors.Validation); ok {
   152  				return ve.ValidateName("device_type")
   153  			} else if ce, ok := err.(*errors.CompositeError); ok {
   154  				return ce.ValidateName("device_type")
   155  			}
   156  			return err
   157  		}
   158  	}
   159  
   160  	return nil
   161  }
   162  
   163  func (m *DeviceBayTemplate) validateLabel(formats strfmt.Registry) error {
   164  	if swag.IsZero(m.Label) { // not required
   165  		return nil
   166  	}
   167  
   168  	if err := validate.MaxLength("label", "body", m.Label, 64); err != nil {
   169  		return err
   170  	}
   171  
   172  	return nil
   173  }
   174  
   175  func (m *DeviceBayTemplate) validateLastUpdated(formats strfmt.Registry) error {
   176  	if swag.IsZero(m.LastUpdated) { // not required
   177  		return nil
   178  	}
   179  
   180  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   181  		return err
   182  	}
   183  
   184  	return nil
   185  }
   186  
   187  func (m *DeviceBayTemplate) validateName(formats strfmt.Registry) error {
   188  
   189  	if err := validate.Required("name", "body", m.Name); err != nil {
   190  		return err
   191  	}
   192  
   193  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   194  		return err
   195  	}
   196  
   197  	if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil {
   198  		return err
   199  	}
   200  
   201  	return nil
   202  }
   203  
   204  func (m *DeviceBayTemplate) validateURL(formats strfmt.Registry) error {
   205  	if swag.IsZero(m.URL) { // not required
   206  		return nil
   207  	}
   208  
   209  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   210  		return err
   211  	}
   212  
   213  	return nil
   214  }
   215  
   216  // ContextValidate validate this device bay template based on the context it is used
   217  func (m *DeviceBayTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   218  	var res []error
   219  
   220  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   221  		res = append(res, err)
   222  	}
   223  
   224  	if err := m.contextValidateDeviceType(ctx, formats); err != nil {
   225  		res = append(res, err)
   226  	}
   227  
   228  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   229  		res = append(res, err)
   230  	}
   231  
   232  	if err := m.contextValidateID(ctx, formats); err != nil {
   233  		res = append(res, err)
   234  	}
   235  
   236  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   237  		res = append(res, err)
   238  	}
   239  
   240  	if err := m.contextValidateURL(ctx, formats); err != nil {
   241  		res = append(res, err)
   242  	}
   243  
   244  	if len(res) > 0 {
   245  		return errors.CompositeValidationError(res...)
   246  	}
   247  	return nil
   248  }
   249  
   250  func (m *DeviceBayTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   251  
   252  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   253  		return err
   254  	}
   255  
   256  	return nil
   257  }
   258  
   259  func (m *DeviceBayTemplate) contextValidateDeviceType(ctx context.Context, formats strfmt.Registry) error {
   260  
   261  	if m.DeviceType != nil {
   262  		if err := m.DeviceType.ContextValidate(ctx, formats); err != nil {
   263  			if ve, ok := err.(*errors.Validation); ok {
   264  				return ve.ValidateName("device_type")
   265  			} else if ce, ok := err.(*errors.CompositeError); ok {
   266  				return ce.ValidateName("device_type")
   267  			}
   268  			return err
   269  		}
   270  	}
   271  
   272  	return nil
   273  }
   274  
   275  func (m *DeviceBayTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   276  
   277  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   278  		return err
   279  	}
   280  
   281  	return nil
   282  }
   283  
   284  func (m *DeviceBayTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   285  
   286  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   287  		return err
   288  	}
   289  
   290  	return nil
   291  }
   292  
   293  func (m *DeviceBayTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   294  
   295  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   296  		return err
   297  	}
   298  
   299  	return nil
   300  }
   301  
   302  func (m *DeviceBayTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   303  
   304  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   305  		return err
   306  	}
   307  
   308  	return nil
   309  }
   310  
   311  // MarshalBinary interface implementation
   312  func (m *DeviceBayTemplate) MarshalBinary() ([]byte, error) {
   313  	if m == nil {
   314  		return nil, nil
   315  	}
   316  	return swag.WriteJSON(m)
   317  }
   318  
   319  // UnmarshalBinary interface implementation
   320  func (m *DeviceBayTemplate) UnmarshalBinary(b []byte) error {
   321  	var res DeviceBayTemplate
   322  	if err := swag.ReadJSON(b, &res); err != nil {
   323  		return err
   324  	}
   325  	*m = res
   326  	return nil
   327  }