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

package experiment_model

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

// V2beta1Experiment v2beta1 experiment
//
// swagger:model v2beta1Experiment
type V2beta1Experiment struct {

	// Output. The time that the experiment was created.
	// Format: date-time
	CreatedAt strfmt.DateTime `json:"created_at,omitempty"`

	// Optional input field. Describes the purpose of the experiment.
	Description string `json:"description,omitempty"`

	// Required input field. Unique experiment name provided by user.
	DisplayName string `json:"display_name,omitempty"`

	// Output. Unique experiment ID. Generated by API server.
	ExperimentID string `json:"experiment_id,omitempty"`

	// Output. The creation time of the last run in this experiment.
	// Format: date-time
	LastRunCreatedAt strfmt.DateTime `json:"last_run_created_at,omitempty"`

	// Optional input field. Specify the namespace this experiment belongs to.
	Namespace string `json:"namespace,omitempty"`

	// Output. Specifies whether this experiment is in archived or available state.
	StorageState *V2beta1ExperimentStorageState `json:"storage_state,omitempty"`
}

// Validate validates this v2beta1 experiment
func (m *V2beta1Experiment) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *V2beta1Experiment) validateCreatedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.CreatedAt) { // not required
		return nil
	}

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

	return nil
}

func (m *V2beta1Experiment) validateLastRunCreatedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.LastRunCreatedAt) { // not required
		return nil
	}

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

	return nil
}

func (m *V2beta1Experiment) validateStorageState(formats strfmt.Registry) error {
	if swag.IsZero(m.StorageState) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *V2beta1Experiment) contextValidateStorageState(ctx context.Context, formats strfmt.Registry) error {

	if m.StorageState != nil {

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

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

	return nil
}

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

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