/*
Portions Copyright (c) Microsoft Corporation.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// 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"
)

// ProvisionProfile provision profile
//
// swagger:model ProvisionProfile
type ProvisionProfile struct {

	// agent pool windows profile
	AgentPoolWindowsProfile *AgentPoolWindowsProfile `json:"agentPoolWindowsProfile,omitempty"`

	// architecture
	// Required: true
	Architecture *string `json:"architecture"`

	// artifact streaming profile
	ArtifactStreamingProfile *ArtifactStreamingProfile `json:"artifactStreamingProfile,omitempty"`

	// custom kubelet config
	CustomKubeletConfig *CustomKubeletConfig `json:"customKubeletConfig,omitempty"`

	// custom linux o s config
	CustomLinuxOSConfig *CustomLinuxOSConfig `json:"customLinuxOSConfig,omitempty"`

	// custom node labels
	CustomNodeLabels map[string]string `json:"customNodeLabels,omitempty"`

	// distro
	// Required: true
	Distro *string `json:"distro"`

	// enable f IP s
	EnableFIPS *bool `json:"enableFIPS,omitempty"`

	// gpu instance profile
	GpuInstanceProfile *int32 `json:"gpuInstanceProfile,omitempty"`

	// gpu profile
	GpuProfile *GPUProfile `json:"gpuProfile,omitempty"`

	// kubelet disk type
	KubeletDiskType *int32 `json:"kubeletDiskType,omitempty"`

	// max pods
	// Required: true
	MaxPods *int32 `json:"maxPods"`

	// message of the day
	MessageOfTheDay *string `json:"messageOfTheDay,omitempty"`

	// mode
	// Required: true
	Mode *int32 `json:"mode"`

	// name
	// Required: true
	Name *string `json:"name"`

	// node initialization taints
	NodeInitializationTaints []string `json:"nodeInitializationTaints"`

	// node taints
	NodeTaints []string `json:"nodeTaints"`

	// orchestrator version
	// Required: true
	OrchestratorVersion *string `json:"orchestratorVersion"`

	// os sku
	// Required: true
	OsSku *int32 `json:"osSku"`

	// os type
	// Required: true
	OsType *int32 `json:"osType"`

	// security profile
	SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"`

	// storage profile
	// Required: true
	StorageProfile *string `json:"storageProfile"`

	// vm size
	// Required: true
	VMSize *string `json:"vmSize"`

	// vnet cidrs
	// Required: true
	VnetCidrs []string `json:"vnetCidrs"`

	// vnet subnet ID
	// Required: true
	VnetSubnetID *string `json:"vnetSubnetID"`

	// workload runtime
	WorkloadRuntime *int32 `json:"workloadRuntime,omitempty"`
}

// Validate validates this provision profile
func (m *ProvisionProfile) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *ProvisionProfile) validateAgentPoolWindowsProfile(formats strfmt.Registry) error {
	if swag.IsZero(m.AgentPoolWindowsProfile) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateArchitecture(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateArtifactStreamingProfile(formats strfmt.Registry) error {
	if swag.IsZero(m.ArtifactStreamingProfile) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateCustomKubeletConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.CustomKubeletConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateCustomLinuxOSConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.CustomLinuxOSConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateDistro(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateGpuProfile(formats strfmt.Registry) error {
	if swag.IsZero(m.GpuProfile) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateMaxPods(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateMode(formats strfmt.Registry) error {

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

	return nil
}

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

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

	return nil
}

func (m *ProvisionProfile) validateOrchestratorVersion(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateOsSku(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateOsType(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateSecurityProfile(formats strfmt.Registry) error {
	if swag.IsZero(m.SecurityProfile) { // not required
		return nil
	}

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

	return nil
}

func (m *ProvisionProfile) validateStorageProfile(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateVMSize(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateVnetCidrs(formats strfmt.Registry) error {

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

	return nil
}

func (m *ProvisionProfile) validateVnetSubnetID(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validate this provision profile based on the context it is used
func (m *ProvisionProfile) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

func (m *ProvisionProfile) contextValidateAgentPoolWindowsProfile(ctx context.Context, formats strfmt.Registry) error {

	if m.AgentPoolWindowsProfile != nil {

		if swag.IsZero(m.AgentPoolWindowsProfile) { // not required
			return nil
		}

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

	return nil
}

func (m *ProvisionProfile) contextValidateArtifactStreamingProfile(ctx context.Context, formats strfmt.Registry) error {

	if m.ArtifactStreamingProfile != nil {

		if swag.IsZero(m.ArtifactStreamingProfile) { // not required
			return nil
		}

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

	return nil
}

func (m *ProvisionProfile) contextValidateCustomKubeletConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.CustomKubeletConfig != nil {

		if swag.IsZero(m.CustomKubeletConfig) { // not required
			return nil
		}

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

	return nil
}

func (m *ProvisionProfile) contextValidateCustomLinuxOSConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.CustomLinuxOSConfig != nil {

		if swag.IsZero(m.CustomLinuxOSConfig) { // not required
			return nil
		}

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

	return nil
}

func (m *ProvisionProfile) contextValidateGpuProfile(ctx context.Context, formats strfmt.Registry) error {

	if m.GpuProfile != nil {

		if swag.IsZero(m.GpuProfile) { // not required
			return nil
		}

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

	return nil
}

func (m *ProvisionProfile) contextValidateSecurityProfile(ctx context.Context, formats strfmt.Registry) error {

	if m.SecurityProfile != nil {

		if swag.IsZero(m.SecurityProfile) { // not required
			return nil
		}

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

	return nil
}

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

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