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

package ops

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

// JumpCreateAuthorizationReq jump create authorization req
//
// swagger:model jump.CreateAuthorizationReq
type JumpCreateAuthorizationReq struct {

	// cluster deploy type
	ClusterDeployType JumpJumpClusterDeployType `json:"cluster_deploy_type,omitempty"`

	// cluster id
	ClusterID string `json:"cluster_id,omitempty"`

	// expiration
	Expiration JumpJumpExpiration `json:"expiration,omitempty"`

	// plane
	Plane JumpJumpPlane `json:"plane,omitempty"`

	// privilege
	Privilege JumpJumpPrivilege `json:"privilege,omitempty"`

	// reason
	Reason string `json:"reason,omitempty"`
}

// Validate validates this jump create authorization req
func (m *JumpCreateAuthorizationReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *JumpCreateAuthorizationReq) validateClusterDeployType(formats strfmt.Registry) error {
	if swag.IsZero(m.ClusterDeployType) { // not required
		return nil
	}

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

	return nil
}

func (m *JumpCreateAuthorizationReq) validateExpiration(formats strfmt.Registry) error {
	if swag.IsZero(m.Expiration) { // not required
		return nil
	}

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

	return nil
}

func (m *JumpCreateAuthorizationReq) validatePlane(formats strfmt.Registry) error {
	if swag.IsZero(m.Plane) { // not required
		return nil
	}

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

	return nil
}

func (m *JumpCreateAuthorizationReq) validatePrivilege(formats strfmt.Registry) error {
	if swag.IsZero(m.Privilege) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this jump create authorization req based on the context it is used
func (m *JumpCreateAuthorizationReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *JumpCreateAuthorizationReq) contextValidateClusterDeployType(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

func (m *JumpCreateAuthorizationReq) contextValidateExpiration(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

func (m *JumpCreateAuthorizationReq) contextValidatePlane(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

func (m *JumpCreateAuthorizationReq) contextValidatePrivilege(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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