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

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

// AzureBlobStoreAPIBucketConfiguration azure blob store Api bucket configuration
//
// swagger:model AzureBlobStoreApiBucketConfiguration
type AzureBlobStoreAPIBucketConfiguration struct {

	// Account name found under Access keys for the storage account.
	// Required: true
	AccountName *string `json:"accountName"`

	// The Azure specific authentication details.
	// Required: true
	Authentication *AzureBlobStoreAPIAuthentication `json:"authentication"`

	// The name of an existing container to be used for storage.
	// Required: true
	// Pattern: ^[a-z0-9][a-z0-9-]{2,62}$
	ContainerName *string `json:"containerName"`
}

// Validate validates this azure blob store Api bucket configuration
func (m *AzureBlobStoreAPIBucketConfiguration) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *AzureBlobStoreAPIBucketConfiguration) validateAccountName(formats strfmt.Registry) error {

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

	return nil
}

func (m *AzureBlobStoreAPIBucketConfiguration) validateAuthentication(formats strfmt.Registry) error {

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

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

	return nil
}

func (m *AzureBlobStoreAPIBucketConfiguration) validateContainerName(formats strfmt.Registry) error {

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

	if err := validate.Pattern("containerName", "body", *m.ContainerName, `^[a-z0-9][a-z0-9-]{2,62}$`); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this azure blob store Api bucket configuration based on the context it is used
func (m *AzureBlobStoreAPIBucketConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *AzureBlobStoreAPIBucketConfiguration) contextValidateAuthentication(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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