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