github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_front_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  // WritableFrontPortTemplate writable front port template
    34  //
    35  // swagger:model WritableFrontPortTemplate
    36  type WritableFrontPortTemplate 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  	// Rear port
    77  	// Required: true
    78  	RearPort *int64 `json:"rear_port"`
    79  
    80  	// Rear port position
    81  	// Maximum: 1024
    82  	// Minimum: 1
    83  	RearPortPosition int64 `json:"rear_port_position,omitempty"`
    84  
    85  	// Type
    86  	// Required: true
    87  	// 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]
    88  	Type *string `json:"type"`
    89  
    90  	// Url
    91  	// Read Only: true
    92  	// Format: uri
    93  	URL strfmt.URI `json:"url,omitempty"`
    94  }
    95  
    96  // Validate validates this writable front port template
    97  func (m *WritableFrontPortTemplate) Validate(formats strfmt.Registry) error {
    98  	var res []error
    99  
   100  	if err := m.validateCreated(formats); err != nil {
   101  		res = append(res, err)
   102  	}
   103  
   104  	if err := m.validateDescription(formats); err != nil {
   105  		res = append(res, err)
   106  	}
   107  
   108  	if err := m.validateDeviceType(formats); err != nil {
   109  		res = append(res, err)
   110  	}
   111  
   112  	if err := m.validateLabel(formats); err != nil {
   113  		res = append(res, err)
   114  	}
   115  
   116  	if err := m.validateLastUpdated(formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.validateName(formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.validateRearPort(formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if err := m.validateRearPortPosition(formats); err != nil {
   129  		res = append(res, err)
   130  	}
   131  
   132  	if err := m.validateType(formats); err != nil {
   133  		res = append(res, err)
   134  	}
   135  
   136  	if err := m.validateURL(formats); err != nil {
   137  		res = append(res, err)
   138  	}
   139  
   140  	if len(res) > 0 {
   141  		return errors.CompositeValidationError(res...)
   142  	}
   143  	return nil
   144  }
   145  
   146  func (m *WritableFrontPortTemplate) validateCreated(formats strfmt.Registry) error {
   147  	if swag.IsZero(m.Created) { // not required
   148  		return nil
   149  	}
   150  
   151  	if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil {
   152  		return err
   153  	}
   154  
   155  	return nil
   156  }
   157  
   158  func (m *WritableFrontPortTemplate) validateDescription(formats strfmt.Registry) error {
   159  	if swag.IsZero(m.Description) { // not required
   160  		return nil
   161  	}
   162  
   163  	if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
   164  		return err
   165  	}
   166  
   167  	return nil
   168  }
   169  
   170  func (m *WritableFrontPortTemplate) validateDeviceType(formats strfmt.Registry) error {
   171  
   172  	if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
   173  		return err
   174  	}
   175  
   176  	return nil
   177  }
   178  
   179  func (m *WritableFrontPortTemplate) validateLabel(formats strfmt.Registry) error {
   180  	if swag.IsZero(m.Label) { // not required
   181  		return nil
   182  	}
   183  
   184  	if err := validate.MaxLength("label", "body", m.Label, 64); err != nil {
   185  		return err
   186  	}
   187  
   188  	return nil
   189  }
   190  
   191  func (m *WritableFrontPortTemplate) validateLastUpdated(formats strfmt.Registry) error {
   192  	if swag.IsZero(m.LastUpdated) { // not required
   193  		return nil
   194  	}
   195  
   196  	if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
   197  		return err
   198  	}
   199  
   200  	return nil
   201  }
   202  
   203  func (m *WritableFrontPortTemplate) validateName(formats strfmt.Registry) error {
   204  
   205  	if err := validate.Required("name", "body", m.Name); err != nil {
   206  		return err
   207  	}
   208  
   209  	if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
   210  		return err
   211  	}
   212  
   213  	if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil {
   214  		return err
   215  	}
   216  
   217  	return nil
   218  }
   219  
   220  func (m *WritableFrontPortTemplate) validateRearPort(formats strfmt.Registry) error {
   221  
   222  	if err := validate.Required("rear_port", "body", m.RearPort); err != nil {
   223  		return err
   224  	}
   225  
   226  	return nil
   227  }
   228  
   229  func (m *WritableFrontPortTemplate) validateRearPortPosition(formats strfmt.Registry) error {
   230  	if swag.IsZero(m.RearPortPosition) { // not required
   231  		return nil
   232  	}
   233  
   234  	if err := validate.MinimumInt("rear_port_position", "body", m.RearPortPosition, 1, false); err != nil {
   235  		return err
   236  	}
   237  
   238  	if err := validate.MaximumInt("rear_port_position", "body", m.RearPortPosition, 1024, false); err != nil {
   239  		return err
   240  	}
   241  
   242  	return nil
   243  }
   244  
   245  var writableFrontPortTemplateTypeTypePropEnum []interface{}
   246  
   247  func init() {
   248  	var res []string
   249  	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 {
   250  		panic(err)
   251  	}
   252  	for _, v := range res {
   253  		writableFrontPortTemplateTypeTypePropEnum = append(writableFrontPortTemplateTypeTypePropEnum, v)
   254  	}
   255  }
   256  
   257  const (
   258  
   259  	// WritableFrontPortTemplateTypeNr8p8c captures enum value "8p8c"
   260  	WritableFrontPortTemplateTypeNr8p8c string = "8p8c"
   261  
   262  	// WritableFrontPortTemplateTypeNr8p6c captures enum value "8p6c"
   263  	WritableFrontPortTemplateTypeNr8p6c string = "8p6c"
   264  
   265  	// WritableFrontPortTemplateTypeNr8p4c captures enum value "8p4c"
   266  	WritableFrontPortTemplateTypeNr8p4c string = "8p4c"
   267  
   268  	// WritableFrontPortTemplateTypeNr8p2c captures enum value "8p2c"
   269  	WritableFrontPortTemplateTypeNr8p2c string = "8p2c"
   270  
   271  	// WritableFrontPortTemplateTypeNr6p6c captures enum value "6p6c"
   272  	WritableFrontPortTemplateTypeNr6p6c string = "6p6c"
   273  
   274  	// WritableFrontPortTemplateTypeNr6p4c captures enum value "6p4c"
   275  	WritableFrontPortTemplateTypeNr6p4c string = "6p4c"
   276  
   277  	// WritableFrontPortTemplateTypeNr6p2c captures enum value "6p2c"
   278  	WritableFrontPortTemplateTypeNr6p2c string = "6p2c"
   279  
   280  	// WritableFrontPortTemplateTypeNr4p4c captures enum value "4p4c"
   281  	WritableFrontPortTemplateTypeNr4p4c string = "4p4c"
   282  
   283  	// WritableFrontPortTemplateTypeNr4p2c captures enum value "4p2c"
   284  	WritableFrontPortTemplateTypeNr4p2c string = "4p2c"
   285  
   286  	// WritableFrontPortTemplateTypeGg45 captures enum value "gg45"
   287  	WritableFrontPortTemplateTypeGg45 string = "gg45"
   288  
   289  	// WritableFrontPortTemplateTypeTeraDash4p captures enum value "tera-4p"
   290  	WritableFrontPortTemplateTypeTeraDash4p string = "tera-4p"
   291  
   292  	// WritableFrontPortTemplateTypeTeraDash2p captures enum value "tera-2p"
   293  	WritableFrontPortTemplateTypeTeraDash2p string = "tera-2p"
   294  
   295  	// WritableFrontPortTemplateTypeTeraDash1p captures enum value "tera-1p"
   296  	WritableFrontPortTemplateTypeTeraDash1p string = "tera-1p"
   297  
   298  	// WritableFrontPortTemplateTypeNr110DashPunch captures enum value "110-punch"
   299  	WritableFrontPortTemplateTypeNr110DashPunch string = "110-punch"
   300  
   301  	// WritableFrontPortTemplateTypeBnc captures enum value "bnc"
   302  	WritableFrontPortTemplateTypeBnc string = "bnc"
   303  
   304  	// WritableFrontPortTemplateTypeF captures enum value "f"
   305  	WritableFrontPortTemplateTypeF string = "f"
   306  
   307  	// WritableFrontPortTemplateTypeN captures enum value "n"
   308  	WritableFrontPortTemplateTypeN string = "n"
   309  
   310  	// WritableFrontPortTemplateTypeMrj21 captures enum value "mrj21"
   311  	WritableFrontPortTemplateTypeMrj21 string = "mrj21"
   312  
   313  	// WritableFrontPortTemplateTypeFc captures enum value "fc"
   314  	WritableFrontPortTemplateTypeFc string = "fc"
   315  
   316  	// WritableFrontPortTemplateTypeLc captures enum value "lc"
   317  	WritableFrontPortTemplateTypeLc string = "lc"
   318  
   319  	// WritableFrontPortTemplateTypeLcDashApc captures enum value "lc-apc"
   320  	WritableFrontPortTemplateTypeLcDashApc string = "lc-apc"
   321  
   322  	// WritableFrontPortTemplateTypeLsh captures enum value "lsh"
   323  	WritableFrontPortTemplateTypeLsh string = "lsh"
   324  
   325  	// WritableFrontPortTemplateTypeLshDashApc captures enum value "lsh-apc"
   326  	WritableFrontPortTemplateTypeLshDashApc string = "lsh-apc"
   327  
   328  	// WritableFrontPortTemplateTypeMpo captures enum value "mpo"
   329  	WritableFrontPortTemplateTypeMpo string = "mpo"
   330  
   331  	// WritableFrontPortTemplateTypeMtrj captures enum value "mtrj"
   332  	WritableFrontPortTemplateTypeMtrj string = "mtrj"
   333  
   334  	// WritableFrontPortTemplateTypeSc captures enum value "sc"
   335  	WritableFrontPortTemplateTypeSc string = "sc"
   336  
   337  	// WritableFrontPortTemplateTypeScDashApc captures enum value "sc-apc"
   338  	WritableFrontPortTemplateTypeScDashApc string = "sc-apc"
   339  
   340  	// WritableFrontPortTemplateTypeSt captures enum value "st"
   341  	WritableFrontPortTemplateTypeSt string = "st"
   342  
   343  	// WritableFrontPortTemplateTypeCs captures enum value "cs"
   344  	WritableFrontPortTemplateTypeCs string = "cs"
   345  
   346  	// WritableFrontPortTemplateTypeSn captures enum value "sn"
   347  	WritableFrontPortTemplateTypeSn string = "sn"
   348  
   349  	// WritableFrontPortTemplateTypeSplice captures enum value "splice"
   350  	WritableFrontPortTemplateTypeSplice string = "splice"
   351  )
   352  
   353  // prop value enum
   354  func (m *WritableFrontPortTemplate) validateTypeEnum(path, location string, value string) error {
   355  	if err := validate.EnumCase(path, location, value, writableFrontPortTemplateTypeTypePropEnum, true); err != nil {
   356  		return err
   357  	}
   358  	return nil
   359  }
   360  
   361  func (m *WritableFrontPortTemplate) validateType(formats strfmt.Registry) error {
   362  
   363  	if err := validate.Required("type", "body", m.Type); err != nil {
   364  		return err
   365  	}
   366  
   367  	// value enum
   368  	if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
   369  		return err
   370  	}
   371  
   372  	return nil
   373  }
   374  
   375  func (m *WritableFrontPortTemplate) validateURL(formats strfmt.Registry) error {
   376  	if swag.IsZero(m.URL) { // not required
   377  		return nil
   378  	}
   379  
   380  	if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
   381  		return err
   382  	}
   383  
   384  	return nil
   385  }
   386  
   387  // ContextValidate validate this writable front port template based on the context it is used
   388  func (m *WritableFrontPortTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   389  	var res []error
   390  
   391  	if err := m.contextValidateCreated(ctx, formats); err != nil {
   392  		res = append(res, err)
   393  	}
   394  
   395  	if err := m.contextValidateDisplay(ctx, formats); err != nil {
   396  		res = append(res, err)
   397  	}
   398  
   399  	if err := m.contextValidateID(ctx, formats); err != nil {
   400  		res = append(res, err)
   401  	}
   402  
   403  	if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
   404  		res = append(res, err)
   405  	}
   406  
   407  	if err := m.contextValidateURL(ctx, formats); err != nil {
   408  		res = append(res, err)
   409  	}
   410  
   411  	if len(res) > 0 {
   412  		return errors.CompositeValidationError(res...)
   413  	}
   414  	return nil
   415  }
   416  
   417  func (m *WritableFrontPortTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
   418  
   419  	if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil {
   420  		return err
   421  	}
   422  
   423  	return nil
   424  }
   425  
   426  func (m *WritableFrontPortTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
   427  
   428  	if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
   429  		return err
   430  	}
   431  
   432  	return nil
   433  }
   434  
   435  func (m *WritableFrontPortTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   436  
   437  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   438  		return err
   439  	}
   440  
   441  	return nil
   442  }
   443  
   444  func (m *WritableFrontPortTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
   445  
   446  	if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil {
   447  		return err
   448  	}
   449  
   450  	return nil
   451  }
   452  
   453  func (m *WritableFrontPortTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
   454  
   455  	if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
   456  		return err
   457  	}
   458  
   459  	return nil
   460  }
   461  
   462  // MarshalBinary interface implementation
   463  func (m *WritableFrontPortTemplate) MarshalBinary() ([]byte, error) {
   464  	if m == nil {
   465  		return nil, nil
   466  	}
   467  	return swag.WriteJSON(m)
   468  }
   469  
   470  // UnmarshalBinary interface implementation
   471  func (m *WritableFrontPortTemplate) UnmarshalBinary(b []byte) error {
   472  	var res WritableFrontPortTemplate
   473  	if err := swag.ReadJSON(b, &res); err != nil {
   474  		return err
   475  	}
   476  	*m = res
   477  	return nil
   478  }