// Code generated by go-swagger; DO NOT EDIT.

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package members_models

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag/jsonutils"
	"github.com/go-openapi/swag/typeutils"
	"github.com/go-openapi/validate"
)

// Cluster Tenant-owned infrastructure metadata. TenantID, identity, and audit fields are server-owned.
//
// swagger:model Cluster
type Cluster struct {

	// created by ID
	// Read Only: true
	// Max Length: 36
	CreatedByID *string `json:"CreatedByID,omitempty"`

	// created date
	// Read Only: true
	// Max Length: 64
	CreatedDate *string `json:"CreatedDate,omitempty"`

	// description
	// Max Length: 255
	Description *string `json:"Description,omitempty"`

	// environment
	// Max Length: 255
	Environment *string `json:"Environment,omitempty"`

	// gateway
	// Max Length: 255
	Gateway *string `json:"Gateway,omitempty"`

	// ID
	// Max Length: 36
	ID string `json:"ID,omitempty"`

	// IP address
	// Max Length: 255
	IPAddress *string `json:"IPAddress,omitempty"`

	// last modified by ID
	// Read Only: true
	// Max Length: 36
	LastModifiedByID *string `json:"LastModifiedByID,omitempty"`

	// last modified date
	// Max Length: 64
	LastModifiedDate *string `json:"LastModifiedDate,omitempty"`

	// name
	// Required: true
	// Max Length: 255
	// Min Length: 1
	Name *string `json:"Name"`

	// owner ID
	// Max Length: 36
	OwnerID *string `json:"OwnerID,omitempty"`

	// ref
	// Max Length: 255
	Ref *string `json:"Ref,omitempty"`

	// status
	// Max Length: 255
	Status *string `json:"Status,omitempty"`

	// subnet
	// Max Length: 255
	Subnet *string `json:"Subnet,omitempty"`

	// tenant ID
	// Read Only: true
	// Max Length: 36
	TenantID *string `json:"TenantID,omitempty"`

	// type
	// Max Length: 255
	Type *string `json:"Type,omitempty"`

	// zone
	// Max Length: 255
	Zone *string `json:"Zone,omitempty"`
}

// Validate validates this cluster
func (m *Cluster) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateCreatedByID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateCreatedDate(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateDescription(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateEnvironment(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateGateway(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateIPAddress(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateLastModifiedByID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateLastModifiedDate(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateName(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateOwnerID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateRef(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateStatus(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateSubnet(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateTenantID(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateType(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateZone(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Cluster) validateCreatedByID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.CreatedByID) { // not required
		return nil
	}

	if err := validate.MaxLength("CreatedByID", "body", *m.CreatedByID, 36); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateCreatedDate(formats strfmt.Registry) error {
	if typeutils.IsZero(m.CreatedDate) { // not required
		return nil
	}

	if err := validate.MaxLength("CreatedDate", "body", *m.CreatedDate, 64); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateDescription(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Description) { // not required
		return nil
	}

	if err := validate.MaxLength("Description", "body", *m.Description, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateEnvironment(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Environment) { // not required
		return nil
	}

	if err := validate.MaxLength("Environment", "body", *m.Environment, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateGateway(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Gateway) { // not required
		return nil
	}

	if err := validate.MaxLength("Gateway", "body", *m.Gateway, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.ID) { // not required
		return nil
	}

	if err := validate.MaxLength("ID", "body", m.ID, 36); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateIPAddress(formats strfmt.Registry) error {
	if typeutils.IsZero(m.IPAddress) { // not required
		return nil
	}

	if err := validate.MaxLength("IPAddress", "body", *m.IPAddress, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateLastModifiedByID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.LastModifiedByID) { // not required
		return nil
	}

	if err := validate.MaxLength("LastModifiedByID", "body", *m.LastModifiedByID, 36); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateLastModifiedDate(formats strfmt.Registry) error {
	if typeutils.IsZero(m.LastModifiedDate) { // not required
		return nil
	}

	if err := validate.MaxLength("LastModifiedDate", "body", *m.LastModifiedDate, 64); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateName(formats strfmt.Registry) error {

	if err := validate.Required("Name", "body", m.Name); err != nil {
		return err
	}

	if err := validate.MinLength("Name", "body", *m.Name, 1); err != nil {
		return err
	}

	if err := validate.MaxLength("Name", "body", *m.Name, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateOwnerID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.OwnerID) { // not required
		return nil
	}

	if err := validate.MaxLength("OwnerID", "body", *m.OwnerID, 36); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateRef(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Ref) { // not required
		return nil
	}

	if err := validate.MaxLength("Ref", "body", *m.Ref, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateStatus(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Status) { // not required
		return nil
	}

	if err := validate.MaxLength("Status", "body", *m.Status, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateSubnet(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Subnet) { // not required
		return nil
	}

	if err := validate.MaxLength("Subnet", "body", *m.Subnet, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateTenantID(formats strfmt.Registry) error {
	if typeutils.IsZero(m.TenantID) { // not required
		return nil
	}

	if err := validate.MaxLength("TenantID", "body", *m.TenantID, 36); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateType(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Type) { // not required
		return nil
	}

	if err := validate.MaxLength("Type", "body", *m.Type, 255); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) validateZone(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Zone) { // not required
		return nil
	}

	if err := validate.MaxLength("Zone", "body", *m.Zone, 255); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this cluster based on the context it is used
func (m *Cluster) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateCreatedByID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateCreatedDate(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateLastModifiedByID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateTenantID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Cluster) contextValidateCreatedByID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "CreatedByID", "body", m.CreatedByID); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) contextValidateCreatedDate(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "CreatedDate", "body", m.CreatedDate); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) contextValidateLastModifiedByID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "LastModifiedByID", "body", m.LastModifiedByID); err != nil {
		return err
	}

	return nil
}

func (m *Cluster) contextValidateTenantID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "TenantID", "body", m.TenantID); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *Cluster) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return jsonutils.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *Cluster) UnmarshalBinary(b []byte) error {
	var res Cluster
	if err := jsonutils.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
