// 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"
)

// Secrets20231128ListOpenAppSecretVersionsResponse secrets 20231128 list open app secret versions response
//
// swagger:model secrets_20231128ListOpenAppSecretVersionsResponse
type Secrets20231128ListOpenAppSecretVersionsResponse struct {

	// dynamic instance
	DynamicInstance *Secrets20231128OpenSecretDynamicInstance `json:"dynamic_instance,omitempty"`

	// pagination
	Pagination *CommonPaginationResponse `json:"pagination,omitempty"`

	// rotating versions
	RotatingVersions *Secrets20231128OpenSecretRotatingVersionList `json:"rotating_versions,omitempty"`

	// static versions
	StaticVersions *Secrets20231128OpenSecretStaticVersionList `json:"static_versions,omitempty"`

	// type
	Type string `json:"type,omitempty"`
}

// Validate validates this secrets 20231128 list open app secret versions response
func (m *Secrets20231128ListOpenAppSecretVersionsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) validateDynamicInstance(formats strfmt.Registry) error {
	if swag.IsZero(m.DynamicInstance) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) validatePagination(formats strfmt.Registry) error {
	if swag.IsZero(m.Pagination) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) validateRotatingVersions(formats strfmt.Registry) error {
	if swag.IsZero(m.RotatingVersions) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) validateStaticVersions(formats strfmt.Registry) error {
	if swag.IsZero(m.StaticVersions) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this secrets 20231128 list open app secret versions response based on the context it is used
func (m *Secrets20231128ListOpenAppSecretVersionsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) contextValidateDynamicInstance(ctx context.Context, formats strfmt.Registry) error {

	if m.DynamicInstance != nil {

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

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) contextValidatePagination(ctx context.Context, formats strfmt.Registry) error {

	if m.Pagination != nil {

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

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) contextValidateRotatingVersions(ctx context.Context, formats strfmt.Registry) error {

	if m.RotatingVersions != nil {

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

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

	return nil
}

func (m *Secrets20231128ListOpenAppSecretVersionsResponse) contextValidateStaticVersions(ctx context.Context, formats strfmt.Registry) error {

	if m.StaticVersions != nil {

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

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

	return nil
}

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

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