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

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 (
	"context"

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

// Secrets20231128Gateway secrets 20231128 gateway
//
// swagger:model secrets_20231128Gateway
type Secrets20231128Gateway struct {

	// hostname
	Hostname string `json:"hostname,omitempty"`

	// id
	ID string `json:"id,omitempty"`

	// metadata
	Metadata map[string]string `json:"metadata,omitempty"`

	// os
	Os string `json:"os,omitempty"`

	// status
	Status *Secrets20231128GatewayStatus `json:"status,omitempty"`

	// status message
	StatusMessage string `json:"status_message,omitempty"`

	// version
	Version string `json:"version,omitempty"`

	// version status
	VersionStatus *GatewayVersionStatus `json:"version_status,omitempty"`
}

// Validate validates this secrets 20231128 gateway
func (m *Secrets20231128Gateway) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

	if m.Status != nil {
		if err := m.Status.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("status")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("status")
			}
			return err
		}
	}

	return nil
}

func (m *Secrets20231128Gateway) validateVersionStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.VersionStatus) { // not required
		return nil
	}

	if m.VersionStatus != nil {
		if err := m.VersionStatus.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("version_status")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("version_status")
			}
			return err
		}
	}

	return nil
}

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

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

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

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

func (m *Secrets20231128Gateway) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.Status != nil {

		if swag.IsZero(m.Status) { // not required
			return nil
		}

		if err := m.Status.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("status")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("status")
			}
			return err
		}
	}

	return nil
}

func (m *Secrets20231128Gateway) contextValidateVersionStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.VersionStatus != nil {

		if swag.IsZero(m.VersionStatus) { // not required
			return nil
		}

		if err := m.VersionStatus.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("version_status")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("version_status")
			}
			return err
		}
	}

	return nil
}

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

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