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