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

// HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse hashicorp cloud consul telemetry 20230414 get service topology response
//
// swagger:model hashicorp.cloud.consul_telemetry_20230414.GetServiceTopologyResponse
type HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse struct {

	// graph is the service topology graph where nodes are services and edges are created for those with connections/requests
	// between those services.
	Graph *HashicorpCloudConsulTelemetry20230414ServiceTopology `json:"graph,omitempty"`
}

// Validate validates this hashicorp cloud consul telemetry 20230414 get service topology response
func (m *HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse) validateGraph(formats strfmt.Registry) error {
	if swag.IsZero(m.Graph) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud consul telemetry 20230414 get service topology response based on the context it is used
func (m *HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudConsulTelemetry20230414GetServiceTopologyResponse) contextValidateGraph(ctx context.Context, formats strfmt.Registry) error {

	if m.Graph != nil {

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

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

	return nil
}

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

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