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

// HashicorpCloudNetwork20200907PrivateLinkService PrivateLinkService represents a PrivateLinkService in HVD cluster i.e. Inbound for HVD
//
// swagger:model hashicorp.cloud.network_20200907.PrivateLinkService
type HashicorpCloudNetwork20200907PrivateLinkService struct {

	// Consumer accounts as Allowed Principals to access the private_link service.
	// IAM Principals in AWS
	// Azure Subscription/Resource IDs in Azure
	ConsumerAccounts []string `json:"consumer_accounts"`

	// Consumer IP ranges or CIDRs to access the HVD cluster associated with the private_link service.
	ConsumerIPRanges []string `json:"consumer_ip_ranges"`

	// Consumer cloud provider regions to support in private_link service
	ConsumerRegions []string `json:"consumer_regions"`

	// Timestamp when PrivateLink was originally created
	//
	// Output only.
	// Read Only: true
	// Format: date-time
	CreatedAt strfmt.DateTime `json:"created_at,omitempty"`

	// Default region supported for the private_link service. It is the HVN region
	//
	// Output only.
	// Read Only: true
	DefaultRegion string `json:"default_region,omitempty"`

	// PrivateLink Service name generated by the cloud provider.
	// In AWS this is the name of the VPC Endpoint Service name
	//
	// Output only.
	// Read Only: true
	ExternalName string `json:"external_name,omitempty"`

	// HVN is a link to the HVN where the PrivateLinkService is associated to.
	Hvn *cloud.HashicorpCloudLocationLink `json:"hvn,omitempty"`

	// id is the user set, slug identifier for the PrivateLinkService. It is unique within a
	// given project but not globally unique. For a globally unique identifier, refer to internal_id.
	ID string `json:"id,omitempty"`

	// State is the state of a PrivateLinkService
	//
	// Output only.
	// Read Only: true
	State *HashicorpCloudNetwork20200907PrivateLinkServiceState `json:"state,omitempty"`

	// UpdatedAt is a timestamp when PrivateLink was last updated.
	//
	// Output only.
	// Read Only: true
	// Format: date-time
	UpdatedAt strfmt.DateTime `json:"updated_at,omitempty"`

	// vault_cluster_id is HVD cluster's slug id
	VaultClusterID string `json:"vault_cluster_id,omitempty"`
}

// Validate validates this hashicorp cloud network 20200907 private link service
func (m *HashicorpCloudNetwork20200907PrivateLinkService) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *HashicorpCloudNetwork20200907PrivateLinkService) validateCreatedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.CreatedAt) { // not required
		return nil
	}

	if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) validateHvn(formats strfmt.Registry) error {
	if swag.IsZero(m.Hvn) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) validateState(formats strfmt.Registry) error {
	if swag.IsZero(m.State) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) validateUpdatedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.UpdatedAt) { // not required
		return nil
	}

	if err := validate.FormatOf("updated_at", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

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

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

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

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

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

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

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

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

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateCreatedAt(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "created_at", "body", strfmt.DateTime(m.CreatedAt)); err != nil {
		return err
	}

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateDefaultRegion(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "default_region", "body", string(m.DefaultRegion)); err != nil {
		return err
	}

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateExternalName(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "external_name", "body", string(m.ExternalName)); err != nil {
		return err
	}

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateHvn(ctx context.Context, formats strfmt.Registry) error {

	if m.Hvn != nil {

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

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

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateState(ctx context.Context, formats strfmt.Registry) error {

	if m.State != nil {

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

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

	return nil
}

func (m *HashicorpCloudNetwork20200907PrivateLinkService) contextValidateUpdatedAt(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "updated_at", "body", strfmt.DateTime(m.UpdatedAt)); err != nil {
		return err
	}

	return nil
}

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

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