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

// HashicorpCloudNetwork20200907NetworkProviderNetworkData ProviderNetworkData contains information about the underlying cloud provider network.
//
// swagger:model hashicorp.cloud.network_20200907.Network.ProviderNetworkData
type HashicorpCloudNetwork20200907NetworkProviderNetworkData struct {

	// aws network data
	AwsNetworkData *HashicorpCloudNetwork20200907AWSNetworkData `json:"aws_network_data,omitempty"`

	// azure network data
	AzureNetworkData HashicorpCloudNetwork20200907AzureNetworkData `json:"azure_network_data,omitempty"`
}

// Validate validates this hashicorp cloud network 20200907 network provider network data
func (m *HashicorpCloudNetwork20200907NetworkProviderNetworkData) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudNetwork20200907NetworkProviderNetworkData) validateAwsNetworkData(formats strfmt.Registry) error {
	if swag.IsZero(m.AwsNetworkData) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud network 20200907 network provider network data based on the context it is used
func (m *HashicorpCloudNetwork20200907NetworkProviderNetworkData) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudNetwork20200907NetworkProviderNetworkData) contextValidateAwsNetworkData(ctx context.Context, formats strfmt.Registry) error {

	if m.AwsNetworkData != nil {

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

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

	return nil
}

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

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