// 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"
	"github.com/go-openapi/validate"
)

// Secrets20231128RotatingSecretState secrets 20231128 rotating secret state
//
// swagger:model secrets_20231128RotatingSecretState
type Secrets20231128RotatingSecretState struct {

	// error message
	ErrorMessage string `json:"error_message,omitempty"`

	// latest version
	LatestVersion int64 `json:"latest_version,omitempty"`

	// rotation time next
	// Format: date-time
	RotationTimeNext strfmt.DateTime `json:"rotation_time_next,omitempty"`

	// rotation time previous
	// Format: date-time
	RotationTimePrevious strfmt.DateTime `json:"rotation_time_previous,omitempty"`

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

	// status previous
	StatusPrevious *Secrets20231128RotatingSecretStatus `json:"status_previous,omitempty"`
}

// Validate validates this secrets 20231128 rotating secret state
func (m *Secrets20231128RotatingSecretState) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *Secrets20231128RotatingSecretState) validateRotationTimeNext(formats strfmt.Registry) error {
	if swag.IsZero(m.RotationTimeNext) { // not required
		return nil
	}

	if err := validate.FormatOf("rotation_time_next", "body", "date-time", m.RotationTimeNext.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *Secrets20231128RotatingSecretState) validateRotationTimePrevious(formats strfmt.Registry) error {
	if swag.IsZero(m.RotationTimePrevious) { // not required
		return nil
	}

	if err := validate.FormatOf("rotation_time_previous", "body", "date-time", m.RotationTimePrevious.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *Secrets20231128RotatingSecretState) 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 *Secrets20231128RotatingSecretState) validateStatusPrevious(formats strfmt.Registry) error {
	if swag.IsZero(m.StatusPrevious) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this secrets 20231128 rotating secret state based on the context it is used
func (m *Secrets20231128RotatingSecretState) 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.contextValidateStatusPrevious(ctx, formats); err != nil {
		res = append(res, err)
	}

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

func (m *Secrets20231128RotatingSecretState) 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 *Secrets20231128RotatingSecretState) contextValidateStatusPrevious(ctx context.Context, formats strfmt.Registry) error {

	if m.StatusPrevious != nil {

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

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

	return nil
}

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

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