| // Code generated by go-swagger; DO NOT EDIT. |
| |
| // Copyright 2018 The go-netbox Authors. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| package models |
| |
| // This file was generated by the swagger tool. |
| // Editing this file might prove futile when you re-run the swagger generate command |
| |
| import ( |
| "encoding/json" |
| |
| strfmt "github.com/go-openapi/strfmt" |
| |
| "github.com/go-openapi/errors" |
| "github.com/go-openapi/swag" |
| "github.com/go-openapi/validate" |
| ) |
| |
| // WritableGraph writable graph |
| // swagger:model WritableGraph |
| type WritableGraph struct { |
| |
| // ID |
| // Read Only: true |
| ID int64 `json:"id,omitempty"` |
| |
| // Link URL |
| // Max Length: 200 |
| Link strfmt.URI `json:"link,omitempty"` |
| |
| // Name |
| // Required: true |
| // Max Length: 100 |
| Name *string `json:"name"` |
| |
| // Source URL |
| // Required: true |
| // Max Length: 500 |
| Source *string `json:"source"` |
| |
| // Type |
| // Required: true |
| Type *int64 `json:"type"` |
| |
| // Weight |
| // Maximum: 32767 |
| // Minimum: 0 |
| Weight *int64 `json:"weight,omitempty"` |
| } |
| |
| // Validate validates this writable graph |
| func (m *WritableGraph) Validate(formats strfmt.Registry) error { |
| var res []error |
| |
| if err := m.validateLink(formats); err != nil { |
| // prop |
| res = append(res, err) |
| } |
| |
| if err := m.validateName(formats); err != nil { |
| // prop |
| res = append(res, err) |
| } |
| |
| if err := m.validateSource(formats); err != nil { |
| // prop |
| res = append(res, err) |
| } |
| |
| if err := m.validateType(formats); err != nil { |
| // prop |
| res = append(res, err) |
| } |
| |
| if err := m.validateWeight(formats); err != nil { |
| // prop |
| res = append(res, err) |
| } |
| |
| if len(res) > 0 { |
| return errors.CompositeValidationError(res...) |
| } |
| return nil |
| } |
| |
| func (m *WritableGraph) validateLink(formats strfmt.Registry) error { |
| |
| if swag.IsZero(m.Link) { // not required |
| return nil |
| } |
| |
| if err := validate.MaxLength("link", "body", string(m.Link), 200); err != nil { |
| return err |
| } |
| |
| if err := validate.FormatOf("link", "body", "uri", m.Link.String(), formats); err != nil { |
| return err |
| } |
| |
| return nil |
| } |
| |
| func (m *WritableGraph) validateName(formats strfmt.Registry) error { |
| |
| if err := validate.Required("name", "body", m.Name); err != nil { |
| return err |
| } |
| |
| if err := validate.MaxLength("name", "body", string(*m.Name), 100); err != nil { |
| return err |
| } |
| |
| return nil |
| } |
| |
| func (m *WritableGraph) validateSource(formats strfmt.Registry) error { |
| |
| if err := validate.Required("source", "body", m.Source); err != nil { |
| return err |
| } |
| |
| if err := validate.MaxLength("source", "body", string(*m.Source), 500); err != nil { |
| return err |
| } |
| |
| return nil |
| } |
| |
| var writableGraphTypeTypePropEnum []interface{} |
| |
| func init() { |
| var res []int64 |
| if err := json.Unmarshal([]byte(`[100,200,300]`), &res); err != nil { |
| panic(err) |
| } |
| for _, v := range res { |
| writableGraphTypeTypePropEnum = append(writableGraphTypeTypePropEnum, v) |
| } |
| } |
| |
| // prop value enum |
| func (m *WritableGraph) validateTypeEnum(path, location string, value int64) error { |
| if err := validate.Enum(path, location, value, writableGraphTypeTypePropEnum); err != nil { |
| return err |
| } |
| return nil |
| } |
| |
| func (m *WritableGraph) validateType(formats strfmt.Registry) error { |
| |
| if err := validate.Required("type", "body", m.Type); err != nil { |
| return err |
| } |
| |
| // value enum |
| if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { |
| return err |
| } |
| |
| return nil |
| } |
| |
| func (m *WritableGraph) validateWeight(formats strfmt.Registry) error { |
| |
| if swag.IsZero(m.Weight) { // not required |
| return nil |
| } |
| |
| if err := validate.MinimumInt("weight", "body", int64(*m.Weight), 0, false); err != nil { |
| return err |
| } |
| |
| if err := validate.MaximumInt("weight", "body", int64(*m.Weight), 32767, false); err != nil { |
| return err |
| } |
| |
| return nil |
| } |
| |
| // MarshalBinary interface implementation |
| func (m *WritableGraph) MarshalBinary() ([]byte, error) { |
| if m == nil { |
| return nil, nil |
| } |
| return swag.WriteJSON(m) |
| } |
| |
| // UnmarshalBinary interface implementation |
| func (m *WritableGraph) UnmarshalBinary(b []byte) error { |
| var res WritableGraph |
| if err := swag.ReadJSON(b, &res); err != nil { |
| return err |
| } |
| *m = res |
| return nil |
| } |