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

// DockerProxyAttributes docker proxy attributes
//
// swagger:model DockerProxyAttributes
type DockerProxyAttributes struct {

	// Allow Nexus Repository Manager to download and cache foreign layers
	CacheForeignLayers bool `json:"cacheForeignLayers,omitempty"`

	// Regular expressions used to identify URLs that are allowed for foreign layer requests
	ForeignLayerURLWhitelist []string `json:"foreignLayerUrlWhitelist"`

	// Type of Docker Index
	// Example: HUB
	// Enum: [HUB REGISTRY CUSTOM]
	IndexType string `json:"indexType,omitempty"`

	// Url of Docker Index to use
	IndexURL string `json:"indexUrl,omitempty"`
}

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

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

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

var dockerProxyAttributesTypeIndexTypePropEnum []interface{}

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

const (

	// DockerProxyAttributesIndexTypeHUB captures enum value "HUB"
	DockerProxyAttributesIndexTypeHUB string = "HUB"

	// DockerProxyAttributesIndexTypeREGISTRY captures enum value "REGISTRY"
	DockerProxyAttributesIndexTypeREGISTRY string = "REGISTRY"

	// DockerProxyAttributesIndexTypeCUSTOM captures enum value "CUSTOM"
	DockerProxyAttributesIndexTypeCUSTOM string = "CUSTOM"
)

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

func (m *DockerProxyAttributes) validateIndexType(formats strfmt.Registry) error {
	if swag.IsZero(m.IndexType) { // not required
		return nil
	}

	// value enum
	if err := m.validateIndexTypeEnum("indexType", "body", m.IndexType); err != nil {
		return err
	}

	return nil
}

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

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

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