github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_rear_port_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  	"encoding/json"
    26  
    27  	"github.com/go-openapi/errors"
    28  	"github.com/go-openapi/strfmt"
    29  	"github.com/go-openapi/swag"
    30  	"github.com/go-openapi/validate"
    31  )
    32  
    33  // WritableRearPortTemplate writable rear port template
    34  //
    35  // swagger:model WritableRearPortTemplate
    36  type WritableRearPortTemplate struct {
    37  
    38  	// Created
    39  	// Read Only: true
    40  	// Format: date
    41  	Created strfmt.Date `json:"created,omitempty"`
    42  
    43  	// Description
    44  	// Max Length: 200
    45  	Description string `json:"description,omitempty"`
    46  
    47  	// Device type
    48  	// Required: true
    49  	DeviceType *int64 `json:"device_type"`
    50  
    51  	// Display
    52  	// Read Only: true
    53  	Display string `json:"display,omitempty"`
    54  
    55  	// Id
    56  	// Read Only: true
    57  	ID int64 `json:"id,omitempty"`
    58  
    59  	// Label
    60  	//
    61  	// Physical label
    62  	// Max Length: 64
    63  	Label string `json:"label,omitempty"`
    64  
    65  	// Last updated
    66  	// Read Only: true
    67  	// Format: date-time
    68  	LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
    69  
    70  	// Name
    71  	// Required: true
    72  	// Max Length: 64
    73  	// Min Length: 1
    74  	Name *string `json:"name"`
    75  
    76  	// Positions
    77  	// Maximum: 1024
    78  	// Minimum: 1
    79  	Positions int64 `json:"positions,omitempty"`
    80  
    81  	// Type
    82  	// Required: true
    83  	// Enum: [8p8c 8p6c 8p4c 8p2c 6p6c 6p4c 6p2c 4p4c 4p2c gg45 tera-4p tera-2p tera-1p 110-punch bnc f n mrj21 fc lc lc-apc lsh lsh-apc mpo mtrj sc sc-apc st cs sn splice]
    84  	Type *string `json:"type"`
    85  
    86  	// Url
    87  	// Read Only: true
    88  	// Format: uri
    89  	URL strfmt.URI `json:"url,omitempty"`
    90  }
    91  
    92  // Validate validates this writable rear port template
    93  func (m *WritableRearPortTemplate) Validate(formats strfmt.Registry) error {
    94  	var res []error
    95  
    96  	if err := m.validateCreated(formats); err != nil {
    97  		res = append(res, err)
    98  	}
    99  
   100  	if err := m.validateDescription(formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if err := m.validateDeviceType(formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	if err := m.validateLabel(formats); err != nil {
   109  		res = append(res, err)
   110  	}
   111  
   112  	if err := m.validateLastUpdated(formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.validateName(formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.validatePositions(formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.validateType(formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if err := m.validateURL(formats); err != nil {
   129  		res = append(res, err)
   130  	}
   131  
   132  	if len(res) > 0 {
   133  		return errors.CompositeValidationError(res...)
   134  	}
   135  	return nil
   136  }
   137  
   138  func (m *WritableRearPortTemplate) validateCreated(formats strfmt.Registry) error {
   139  	if swag.IsZero(m.Created) { // not required
   140  		return nil
   141  	}
   142  
   143  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   144  		return err
   145  	}
   146  
   147  	return nil
   148  }
   149  
   150  func (m *WritableRearPortTemplate) validateDescription(formats strfmt.Registry) error {
   151  	if swag.IsZero(m.Description) { // not required
   152  		return nil
   153  	}
   154  
   155  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   156  		return err
   157  	}
   158  
   159  	return nil
   160  }
   161  
   162  func (m *WritableRearPortTemplate) validateDeviceType(formats strfmt.Registry) error {
   163  
   164  	if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
   165  		return err
   166  	}
   167  
   168  	return nil
   169  }
   170  
   171  func (m *WritableRearPortTemplate) validateLabel(formats strfmt.Registry) error {
   172  	if swag.IsZero(m.Label) { // not required
   173  		return nil
   174  	}
   175  
   176  	if err := validate.MaxLength("label", "body", m.Label, 64); err != nil {
   177  		return err
   178  	}
   179  
   180  	return nil
   181  }
   182  
   183  func (m *WritableRearPortTemplate) validateLastUpdated(formats strfmt.Registry) error {
   184  	if swag.IsZero(m.LastUpdated) { // not required
   185  		return nil
   186  	}
   187  
   188  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   189  		return err
   190  	}
   191  
   192  	return nil
   193  }
   194  
   195  func (m *WritableRearPortTemplate) validateName(formats strfmt.Registry) error {
   196  
   197  	if err := validate.Required("name", "body", m.Name); err != nil {
   198  		return err
   199  	}
   200  
   201  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   202  		return err
   203  	}
   204  
   205  	if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil {
   206  		return err
   207  	}
   208  
   209  	return nil
   210  }
   211  
   212  func (m *WritableRearPortTemplate) validatePositions(formats strfmt.Registry) error {
   213  	if swag.IsZero(m.Positions) { // not required
   214  		return nil
   215  	}
   216  
   217  	if err := validate.MinimumInt("positions", "body", m.Positions, 1, false); err != nil {
   218  		return err
   219  	}
   220  
   221  	if err := validate.MaximumInt("positions", "body", m.Positions, 1024, false); err != nil {
   222  		return err
   223  	}
   224  
   225  	return nil
   226  }
   227  
   228  var writableRearPortTemplateTypeTypePropEnum []interface{}
   229  
   230  func init() {
   231  	var res []string
   232  	if err := json.Unmarshal([]byte(`["8p8c","8p6c","8p4c","8p2c","6p6c","6p4c","6p2c","4p4c","4p2c","gg45","tera-4p","tera-2p","tera-1p","110-punch","bnc","f","n","mrj21","fc","lc","lc-apc","lsh","lsh-apc","mpo","mtrj","sc","sc-apc","st","cs","sn","splice"]`), &res); err != nil {
   233  		panic(err)
   234  	}
   235  	for _, v := range res {
   236  		writableRearPortTemplateTypeTypePropEnum = append(writableRearPortTemplateTypeTypePropEnum, v)
   237  	}
   238  }
   239  
   240  const (
   241  
   242  	// WritableRearPortTemplateTypeNr8p8c captures enum value "8p8c"
   243  	WritableRearPortTemplateTypeNr8p8c string = "8p8c"
   244  
   245  	// WritableRearPortTemplateTypeNr8p6c captures enum value "8p6c"
   246  	WritableRearPortTemplateTypeNr8p6c string = "8p6c"
   247  
   248  	// WritableRearPortTemplateTypeNr8p4c captures enum value "8p4c"
   249  	WritableRearPortTemplateTypeNr8p4c string = "8p4c"
   250  
   251  	// WritableRearPortTemplateTypeNr8p2c captures enum value "8p2c"
   252  	WritableRearPortTemplateTypeNr8p2c string = "8p2c"
   253  
   254  	// WritableRearPortTemplateTypeNr6p6c captures enum value "6p6c"
   255  	WritableRearPortTemplateTypeNr6p6c string = "6p6c"
   256  
   257  	// WritableRearPortTemplateTypeNr6p4c captures enum value "6p4c"
   258  	WritableRearPortTemplateTypeNr6p4c string = "6p4c"
   259  
   260  	// WritableRearPortTemplateTypeNr6p2c captures enum value "6p2c"
   261  	WritableRearPortTemplateTypeNr6p2c string = "6p2c"
   262  
   263  	// WritableRearPortTemplateTypeNr4p4c captures enum value "4p4c"
   264  	WritableRearPortTemplateTypeNr4p4c string = "4p4c"
   265  
   266  	// WritableRearPortTemplateTypeNr4p2c captures enum value "4p2c"
   267  	WritableRearPortTemplateTypeNr4p2c string = "4p2c"
   268  
   269  	// WritableRearPortTemplateTypeGg45 captures enum value "gg45"
   270  	WritableRearPortTemplateTypeGg45 string = "gg45"
   271  
   272  	// WritableRearPortTemplateTypeTeraDash4p captures enum value "tera-4p"
   273  	WritableRearPortTemplateTypeTeraDash4p string = "tera-4p"
   274  
   275  	// WritableRearPortTemplateTypeTeraDash2p captures enum value "tera-2p"
   276  	WritableRearPortTemplateTypeTeraDash2p string = "tera-2p"
   277  
   278  	// WritableRearPortTemplateTypeTeraDash1p captures enum value "tera-1p"
   279  	WritableRearPortTemplateTypeTeraDash1p string = "tera-1p"
   280  
   281  	// WritableRearPortTemplateTypeNr110DashPunch captures enum value "110-punch"
   282  	WritableRearPortTemplateTypeNr110DashPunch string = "110-punch"
   283  
   284  	// WritableRearPortTemplateTypeBnc captures enum value "bnc"
   285  	WritableRearPortTemplateTypeBnc string = "bnc"
   286  
   287  	// WritableRearPortTemplateTypeF captures enum value "f"
   288  	WritableRearPortTemplateTypeF string = "f"
   289  
   290  	// WritableRearPortTemplateTypeN captures enum value "n"
   291  	WritableRearPortTemplateTypeN string = "n"
   292  
   293  	// WritableRearPortTemplateTypeMrj21 captures enum value "mrj21"
   294  	WritableRearPortTemplateTypeMrj21 string = "mrj21"
   295  
   296  	// WritableRearPortTemplateTypeFc captures enum value "fc"
   297  	WritableRearPortTemplateTypeFc string = "fc"
   298  
   299  	// WritableRearPortTemplateTypeLc captures enum value "lc"
   300  	WritableRearPortTemplateTypeLc string = "lc"
   301  
   302  	// WritableRearPortTemplateTypeLcDashApc captures enum value "lc-apc"
   303  	WritableRearPortTemplateTypeLcDashApc string = "lc-apc"
   304  
   305  	// WritableRearPortTemplateTypeLsh captures enum value "lsh"
   306  	WritableRearPortTemplateTypeLsh string = "lsh"
   307  
   308  	// WritableRearPortTemplateTypeLshDashApc captures enum value "lsh-apc"
   309  	WritableRearPortTemplateTypeLshDashApc string = "lsh-apc"
   310  
   311  	// WritableRearPortTemplateTypeMpo captures enum value "mpo"
   312  	WritableRearPortTemplateTypeMpo string = "mpo"
   313  
   314  	// WritableRearPortTemplateTypeMtrj captures enum value "mtrj"
   315  	WritableRearPortTemplateTypeMtrj string = "mtrj"
   316  
   317  	// WritableRearPortTemplateTypeSc captures enum value "sc"
   318  	WritableRearPortTemplateTypeSc string = "sc"
   319  
   320  	// WritableRearPortTemplateTypeScDashApc captures enum value "sc-apc"
   321  	WritableRearPortTemplateTypeScDashApc string = "sc-apc"
   322  
   323  	// WritableRearPortTemplateTypeSt captures enum value "st"
   324  	WritableRearPortTemplateTypeSt string = "st"
   325  
   326  	// WritableRearPortTemplateTypeCs captures enum value "cs"
   327  	WritableRearPortTemplateTypeCs string = "cs"
   328  
   329  	// WritableRearPortTemplateTypeSn captures enum value "sn"
   330  	WritableRearPortTemplateTypeSn string = "sn"
   331  
   332  	// WritableRearPortTemplateTypeSplice captures enum value "splice"
   333  	WritableRearPortTemplateTypeSplice string = "splice"
   334  )
   335  
   336  // prop value enum
   337  func (m *WritableRearPortTemplate) validateTypeEnum(path, location string, value string) error {
   338  	if err := validate.EnumCase(path, location, value, writableRearPortTemplateTypeTypePropEnum, true); err != nil {
   339  		return err
   340  	}
   341  	return nil
   342  }
   343  
   344  func (m *WritableRearPortTemplate) validateType(formats strfmt.Registry) error {
   345  
   346  	if err := validate.Required("type", "body", m.Type); err != nil {
   347  		return err
   348  	}
   349  
   350  	// value enum
   351  	if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
   352  		return err
   353  	}
   354  
   355  	return nil
   356  }
   357  
   358  func (m *WritableRearPortTemplate) validateURL(formats strfmt.Registry) error {
   359  	if swag.IsZero(m.URL) { // not required
   360  		return nil
   361  	}
   362  
   363  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   364  		return err
   365  	}
   366  
   367  	return nil
   368  }
   369  
   370  // ContextValidate validate this writable rear port template based on the context it is used
   371  func (m *WritableRearPortTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   372  	var res []error
   373  
   374  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   375  		res = append(res, err)
   376  	}
   377  
   378  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   379  		res = append(res, err)
   380  	}
   381  
   382  	if err := m.contextValidateID(ctx, formats); err != nil {
   383  		res = append(res, err)
   384  	}
   385  
   386  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   387  		res = append(res, err)
   388  	}
   389  
   390  	if err := m.contextValidateURL(ctx, formats); err != nil {
   391  		res = append(res, err)
   392  	}
   393  
   394  	if len(res) > 0 {
   395  		return errors.CompositeValidationError(res...)
   396  	}
   397  	return nil
   398  }
   399  
   400  func (m *WritableRearPortTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   401  
   402  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   403  		return err
   404  	}
   405  
   406  	return nil
   407  }
   408  
   409  func (m *WritableRearPortTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   410  
   411  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   412  		return err
   413  	}
   414  
   415  	return nil
   416  }
   417  
   418  func (m *WritableRearPortTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   419  
   420  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   421  		return err
   422  	}
   423  
   424  	return nil
   425  }
   426  
   427  func (m *WritableRearPortTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   428  
   429  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   430  		return err
   431  	}
   432  
   433  	return nil
   434  }
   435  
   436  func (m *WritableRearPortTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   437  
   438  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   439  		return err
   440  	}
   441  
   442  	return nil
   443  }
   444  
   445  // MarshalBinary interface implementation
   446  func (m *WritableRearPortTemplate) MarshalBinary() ([]byte, error) {
   447  	if m == nil {
   448  		return nil, nil
   449  	}
   450  	return swag.WriteJSON(m)
   451  }
   452  
   453  // UnmarshalBinary interface implementation
   454  func (m *WritableRearPortTemplate) UnmarshalBinary(b []byte) error {
   455  	var res WritableRearPortTemplate
   456  	if err := swag.ReadJSON(b, &res); err != nil {
   457  		return err
   458  	}
   459  	*m = res
   460  	return nil
   461  }