// 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"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// SPPPlacementGroupCreate s p p placement group create
//
// swagger:model SPPPlacementGroupCreate
type SPPPlacementGroupCreate struct {

	// The name of the Shared Processor Pool Placement Group; minimum of 2 characters, maximum of 12, the only special character allowed is the underscore '_'.
	// Required: true
	Name *string `json:"name"`

	// The placement group policy
	// Required: true
	// Enum: [affinity anti-affinity]
	Policy *string `json:"policy"`
}

// Validate validates this s p p placement group create
func (m *SPPPlacementGroupCreate) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *SPPPlacementGroupCreate) validateName(formats strfmt.Registry) error {

	if err := validate.Required("name", "body", m.Name); err != nil {
		return err
	}

	return nil
}

var sPPPlacementGroupCreateTypePolicyPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["affinity","anti-affinity"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		sPPPlacementGroupCreateTypePolicyPropEnum = append(sPPPlacementGroupCreateTypePolicyPropEnum, v)
	}
}

const (

	// SPPPlacementGroupCreatePolicyAffinity captures enum value "affinity"
	SPPPlacementGroupCreatePolicyAffinity string = "affinity"

	// SPPPlacementGroupCreatePolicyAntiDashAffinity captures enum value "anti-affinity"
	SPPPlacementGroupCreatePolicyAntiDashAffinity string = "anti-affinity"
)

// prop value enum
func (m *SPPPlacementGroupCreate) validatePolicyEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, sPPPlacementGroupCreateTypePolicyPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *SPPPlacementGroupCreate) validatePolicy(formats strfmt.Registry) error {

	if err := validate.Required("policy", "body", m.Policy); err != nil {
		return err
	}

	// value enum
	if err := m.validatePolicyEnum("policy", "body", *m.Policy); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this s p p placement group create based on context it is used
func (m *SPPPlacementGroupCreate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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