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

// HostedStorageAttributes hosted storage attributes
//
// swagger:model HostedStorageAttributes
type HostedStorageAttributes struct {

	// Blob store used to store repository contents
	// Example: default
	BlobStoreName string `json:"blobStoreName,omitempty"`

	// Whether to validate uploaded content's MIME type appropriate for the repository format
	// Example: true
	// Required: true
	StrictContentTypeValidation *bool `json:"strictContentTypeValidation"`

	// Controls if deployments of and updates to assets are allowed
	// Example: allow_once
	// Required: true
	// Enum: [allow allow_once deny]
	WritePolicy *string `json:"writePolicy"`
}

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

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

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

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

func (m *HostedStorageAttributes) validateStrictContentTypeValidation(formats strfmt.Registry) error {

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

	return nil
}

var hostedStorageAttributesTypeWritePolicyPropEnum []interface{}

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

const (

	// HostedStorageAttributesWritePolicyAllow captures enum value "allow"
	HostedStorageAttributesWritePolicyAllow string = "allow"

	// HostedStorageAttributesWritePolicyAllowOnce captures enum value "allow_once"
	HostedStorageAttributesWritePolicyAllowOnce string = "allow_once"

	// HostedStorageAttributesWritePolicyDeny captures enum value "deny"
	HostedStorageAttributesWritePolicyDeny string = "deny"
)

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

func (m *HostedStorageAttributes) validateWritePolicy(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateWritePolicyEnum("writePolicy", "body", *m.WritePolicy); err != nil {
		return err
	}

	return nil
}

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

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

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