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

// Secrets20231128ListAppSecretVersionsResponse secrets 20231128 list app secret versions response
//
// swagger:model secrets_20231128ListAppSecretVersionsResponse
type Secrets20231128ListAppSecretVersionsResponse struct {

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

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

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

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

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

	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 *Secrets20231128ListAppSecretVersionsResponse) 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 *Secrets20231128ListAppSecretVersionsResponse) 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 *Secrets20231128ListAppSecretVersionsResponse) 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 app secret versions response based on the context it is used
func (m *Secrets20231128ListAppSecretVersionsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	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 *Secrets20231128ListAppSecretVersionsResponse) 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 *Secrets20231128ListAppSecretVersionsResponse) 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 *Secrets20231128ListAppSecretVersionsResponse) 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 *Secrets20231128ListAppSecretVersionsResponse) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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