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

// NugetAttributes nuget attributes
//
// swagger:model NugetAttributes
type NugetAttributes struct {

	// Nuget protocol version
	// Example: V3
	// Enum: [V2 V3]
	NugetVersion string `json:"nugetVersion,omitempty"`

	// How long to cache query results from the proxied repository (in seconds)
	// Example: 3600
	QueryCacheItemMaxAge int32 `json:"queryCacheItemMaxAge,omitempty"`
}

// Validate validates this nuget attributes
func (m *NugetAttributes) Validate(formats strfmt.Registry) error {
	var res []error

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

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

var nugetAttributesTypeNugetVersionPropEnum []interface{}

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

const (

	// NugetAttributesNugetVersionV2 captures enum value "V2"
	NugetAttributesNugetVersionV2 string = "V2"

	// NugetAttributesNugetVersionV3 captures enum value "V3"
	NugetAttributesNugetVersionV3 string = "V3"
)

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

func (m *NugetAttributes) validateNugetVersion(formats strfmt.Registry) error {
	if swag.IsZero(m.NugetVersion) { // not required
		return nil
	}

	// value enum
	if err := m.validateNugetVersionEnum("nugetVersion", "body", m.NugetVersion); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this nuget attributes based on context it is used
func (m *NugetAttributes) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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