blob: 95819864fb8726eb7a26081c35b1140502b99a82 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 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
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 strfmt "github.com/go-openapi/strfmt"
24
25 "github.com/go-openapi/errors"
26 "github.com/go-openapi/swag"
27 "github.com/go-openapi/validate"
28)
29
30// WritableRegion writable region
31// swagger:model WritableRegion
32type WritableRegion struct {
33
34 // ID
35 // Read Only: true
36 ID int64 `json:"id,omitempty"`
37
38 // Name
39 // Required: true
40 // Max Length: 50
41 Name *string `json:"name"`
42
43 // Parent
44 Parent int64 `json:"parent,omitempty"`
45
46 // Slug
47 // Required: true
48 // Max Length: 50
49 // Pattern: ^[-a-zA-Z0-9_]+$
50 Slug *string `json:"slug"`
51}
52
53// Validate validates this writable region
54func (m *WritableRegion) Validate(formats strfmt.Registry) error {
55 var res []error
56
57 if err := m.validateName(formats); err != nil {
58 // prop
59 res = append(res, err)
60 }
61
62 if err := m.validateSlug(formats); err != nil {
63 // prop
64 res = append(res, err)
65 }
66
67 if len(res) > 0 {
68 return errors.CompositeValidationError(res...)
69 }
70 return nil
71}
72
73func (m *WritableRegion) validateName(formats strfmt.Registry) error {
74
75 if err := validate.Required("name", "body", m.Name); err != nil {
76 return err
77 }
78
79 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
80 return err
81 }
82
83 return nil
84}
85
86func (m *WritableRegion) validateSlug(formats strfmt.Registry) error {
87
88 if err := validate.Required("slug", "body", m.Slug); err != nil {
89 return err
90 }
91
92 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
93 return err
94 }
95
96 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
97 return err
98 }
99
100 return nil
101}
102
103// MarshalBinary interface implementation
104func (m *WritableRegion) MarshalBinary() ([]byte, error) {
105 if m == nil {
106 return nil, nil
107 }
108 return swag.WriteJSON(m)
109}
110
111// UnmarshalBinary interface implementation
112func (m *WritableRegion) UnmarshalBinary(b []byte) error {
113 var res WritableRegion
114 if err := swag.ReadJSON(b, &res); err != nil {
115 return err
116 }
117 *m = res
118 return nil
119}