1// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright Prometheus Team
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
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	"encoding/json"
24	"strconv"
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// ClusterStatus cluster status
33//
34// swagger:model clusterStatus
35type ClusterStatus struct {
36
37	// name
38	Name string `json:"name,omitempty"`
39
40	// peers
41	Peers []*PeerStatus `json:"peers"`
42
43	// status
44	// Required: true
45	// Enum: [ready settling disabled]
46	Status *string `json:"status"`
47}
48
49// Validate validates this cluster status
50func (m *ClusterStatus) Validate(formats strfmt.Registry) error {
51	var res []error
52
53	if err := m.validatePeers(formats); err != nil {
54		res = append(res, err)
55	}
56
57	if err := m.validateStatus(formats); err != nil {
58		res = append(res, err)
59	}
60
61	if len(res) > 0 {
62		return errors.CompositeValidationError(res...)
63	}
64	return nil
65}
66
67func (m *ClusterStatus) validatePeers(formats strfmt.Registry) error {
68
69	if swag.IsZero(m.Peers) { // not required
70		return nil
71	}
72
73	for i := 0; i < len(m.Peers); i++ {
74		if swag.IsZero(m.Peers[i]) { // not required
75			continue
76		}
77
78		if m.Peers[i] != nil {
79			if err := m.Peers[i].Validate(formats); err != nil {
80				if ve, ok := err.(*errors.Validation); ok {
81					return ve.ValidateName("peers" + "." + strconv.Itoa(i))
82				}
83				return err
84			}
85		}
86
87	}
88
89	return nil
90}
91
92var clusterStatusTypeStatusPropEnum []interface{}
93
94func init() {
95	var res []string
96	if err := json.Unmarshal([]byte(`["ready","settling","disabled"]`), &res); err != nil {
97		panic(err)
98	}
99	for _, v := range res {
100		clusterStatusTypeStatusPropEnum = append(clusterStatusTypeStatusPropEnum, v)
101	}
102}
103
104const (
105
106	// ClusterStatusStatusReady captures enum value "ready"
107	ClusterStatusStatusReady string = "ready"
108
109	// ClusterStatusStatusSettling captures enum value "settling"
110	ClusterStatusStatusSettling string = "settling"
111
112	// ClusterStatusStatusDisabled captures enum value "disabled"
113	ClusterStatusStatusDisabled string = "disabled"
114)
115
116// prop value enum
117func (m *ClusterStatus) validateStatusEnum(path, location string, value string) error {
118	if err := validate.EnumCase(path, location, value, clusterStatusTypeStatusPropEnum, true); err != nil {
119		return err
120	}
121	return nil
122}
123
124func (m *ClusterStatus) validateStatus(formats strfmt.Registry) error {
125
126	if err := validate.Required("status", "body", m.Status); err != nil {
127		return err
128	}
129
130	// value enum
131	if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
132		return err
133	}
134
135	return nil
136}
137
138// MarshalBinary interface implementation
139func (m *ClusterStatus) MarshalBinary() ([]byte, error) {
140	if m == nil {
141		return nil, nil
142	}
143	return swag.WriteJSON(m)
144}
145
146// UnmarshalBinary interface implementation
147func (m *ClusterStatus) UnmarshalBinary(b []byte) error {
148	var res ClusterStatus
149	if err := swag.ReadJSON(b, &res); err != nil {
150		return err
151	}
152	*m = res
153	return nil
154}
155