// 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"
	cloud "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models"
)

// HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse hashicorp cloud global network manager 20220215 get aggregate service summary response
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.GetAggregateServiceSummaryResponse
type HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse struct {

	// aggregate_service_summary_by_kind breaks down service instance health by Service Kind.
	AggregateServiceSummaryByKind map[string]HashicorpCloudGlobalNetworkManager20220215AggregateServiceSummary `json:"aggregate_service_summary_by_kind,omitempty"`

	// critical service instances
	CriticalServiceInstances int32 `json:"critical_service_instances,omitempty"`

	// location is the location of the services with an optional provider and region
	Location *cloud.HashicorpCloudLocationLocation `json:"location,omitempty"`

	// passing service instances
	PassingServiceInstances int32 `json:"passing_service_instances,omitempty"`

	// total service instances
	TotalServiceInstances int32 `json:"total_service_instances,omitempty"`

	// TODO: remove these fields in favor of just returning aggregate_service_summary_by_kind.
	// aggregate_service_summary_by_kind can be reduced to total fields (which this is currently).
	TotalServices int32 `json:"total_services,omitempty"`

	// warning service instances
	WarningServiceInstances int32 `json:"warning_service_instances,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 get aggregate service summary response
func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) validateAggregateServiceSummaryByKind(formats strfmt.Registry) error {
	if swag.IsZero(m.AggregateServiceSummaryByKind) { // not required
		return nil
	}

	for k := range m.AggregateServiceSummaryByKind {

		if err := validate.Required("aggregate_service_summary_by_kind"+"."+k, "body", m.AggregateServiceSummaryByKind[k]); err != nil {
			return err
		}
		if val, ok := m.AggregateServiceSummaryByKind[k]; ok {
			if err := val.Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("aggregate_service_summary_by_kind" + "." + k)
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("aggregate_service_summary_by_kind" + "." + k)
				}
				return err
			}
		}

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) validateLocation(formats strfmt.Registry) error {
	if swag.IsZero(m.Location) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud global network manager 20220215 get aggregate service summary response based on the context it is used
func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) contextValidateAggregateServiceSummaryByKind(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.AggregateServiceSummaryByKind {

		if val, ok := m.AggregateServiceSummaryByKind[k]; ok {
			if err := val.ContextValidate(ctx, formats); err != nil {
				return err
			}
		}

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215GetAggregateServiceSummaryResponse) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error {

	if m.Location != nil {

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

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

	return nil
}

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

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