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

// HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata ServerTLSMetadata is the TLS metadata that Consul server pushes up to GNM.
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.ServerTLSMetadata
type HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata struct {

	// internal_rpc defines TLS configuration for the net/rpc protocol used
	// between Consul agents.
	InternalRPC *HashicorpCloudGlobalNetworkManager20220215TLSInfo `json:"internal_rpc,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 server TLS metadata
func (m *HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata) validateInternalRPC(formats strfmt.Registry) error {
	if swag.IsZero(m.InternalRPC) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud global network manager 20220215 server TLS metadata based on the context it is used
func (m *HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215ServerTLSMetadata) contextValidateInternalRPC(ctx context.Context, formats strfmt.Registry) error {

	if m.InternalRPC != nil {

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

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

	return nil
}

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

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