github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_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  // WritableDeviceBayTemplate writable device bay template
    33  //
    34  // swagger:model WritableDeviceBayTemplate
    35  type WritableDeviceBayTemplate 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 *int64 `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 writable device bay template
    82  func (m *WritableDeviceBayTemplate) 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 *WritableDeviceBayTemplate) 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 *WritableDeviceBayTemplate) 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 *WritableDeviceBayTemplate) validateDeviceType(formats strfmt.Registry) error {
   144  
   145  	if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
   146  		return err
   147  	}
   148  
   149  	return nil
   150  }
   151  
   152  func (m *WritableDeviceBayTemplate) validateLabel(formats strfmt.Registry) error {
   153  	if swag.IsZero(m.Label) { // not required
   154  		return nil
   155  	}
   156  
   157  	if err := validate.MaxLength("label", "body", m.Label, 64); err != nil {
   158  		return err
   159  	}
   160  
   161  	return nil
   162  }
   163  
   164  func (m *WritableDeviceBayTemplate) validateLastUpdated(formats strfmt.Registry) error {
   165  	if swag.IsZero(m.LastUpdated) { // not required
   166  		return nil
   167  	}
   168  
   169  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   170  		return err
   171  	}
   172  
   173  	return nil
   174  }
   175  
   176  func (m *WritableDeviceBayTemplate) validateName(formats strfmt.Registry) error {
   177  
   178  	if err := validate.Required("name", "body", m.Name); err != nil {
   179  		return err
   180  	}
   181  
   182  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   183  		return err
   184  	}
   185  
   186  	if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil {
   187  		return err
   188  	}
   189  
   190  	return nil
   191  }
   192  
   193  func (m *WritableDeviceBayTemplate) validateURL(formats strfmt.Registry) error {
   194  	if swag.IsZero(m.URL) { // not required
   195  		return nil
   196  	}
   197  
   198  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   199  		return err
   200  	}
   201  
   202  	return nil
   203  }
   204  
   205  // ContextValidate validate this writable device bay template based on the context it is used
   206  func (m *WritableDeviceBayTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   207  	var res []error
   208  
   209  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   210  		res = append(res, err)
   211  	}
   212  
   213  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   214  		res = append(res, err)
   215  	}
   216  
   217  	if err := m.contextValidateID(ctx, formats); err != nil {
   218  		res = append(res, err)
   219  	}
   220  
   221  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   222  		res = append(res, err)
   223  	}
   224  
   225  	if err := m.contextValidateURL(ctx, formats); err != nil {
   226  		res = append(res, err)
   227  	}
   228  
   229  	if len(res) > 0 {
   230  		return errors.CompositeValidationError(res...)
   231  	}
   232  	return nil
   233  }
   234  
   235  func (m *WritableDeviceBayTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   236  
   237  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   238  		return err
   239  	}
   240  
   241  	return nil
   242  }
   243  
   244  func (m *WritableDeviceBayTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   245  
   246  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   247  		return err
   248  	}
   249  
   250  	return nil
   251  }
   252  
   253  func (m *WritableDeviceBayTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   254  
   255  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   256  		return err
   257  	}
   258  
   259  	return nil
   260  }
   261  
   262  func (m *WritableDeviceBayTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   263  
   264  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   265  		return err
   266  	}
   267  
   268  	return nil
   269  }
   270  
   271  func (m *WritableDeviceBayTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   272  
   273  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   274  		return err
   275  	}
   276  
   277  	return nil
   278  }
   279  
   280  // MarshalBinary interface implementation
   281  func (m *WritableDeviceBayTemplate) MarshalBinary() ([]byte, error) {
   282  	if m == nil {
   283  		return nil, nil
   284  	}
   285  	return swag.WriteJSON(m)
   286  }
   287  
   288  // UnmarshalBinary interface implementation
   289  func (m *WritableDeviceBayTemplate) UnmarshalBinary(b []byte) error {
   290  	var res WritableDeviceBayTemplate
   291  	if err := swag.ReadJSON(b, &res); err != nil {
   292  		return err
   293  	}
   294  	*m = res
   295  	return nil
   296  }