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

// HashicorpCloudNetwork20200907UpdatePrivateLinkServiceRequest hashicorp cloud network 20200907 update private link service request
//
// swagger:model hashicorp.cloud.network_20200907.UpdatePrivateLinkServiceRequest
type HashicorpCloudNetwork20200907UpdatePrivateLinkServiceRequest struct {

	// Consumer accounts to add as Allowed Principals to be allowed to access the private_link service.
	// IAM Principals in AWS
	// Azure Subscription/Resource IDs in Azure
	AddConsumerAccounts []string `json:"add_consumer_accounts"`

	// Consumer IP ranges or CIDRs to be added to access the HVD cluster associated with the private_link service.
	AddConsumerIPRanges []string `json:"add_consumer_ip_ranges"`

	// Consumer cloud provider regions to add to the private_link service
	AddConsumerRegions []string `json:"add_consumer_regions"`

	// HVN is the link to the HVN where the private_link belongs
	Hvn *cloud.HashicorpCloudLocationLink `json:"hvn,omitempty"`

	// Id is the ID of the private_link to update
	ID string `json:"id,omitempty"`

	// Consumer accounts to remove as Allowed Principals from the private_link service.
	// IAM Principals in AWS
	// Azure Subscription/Resource IDs in Azure
	RemoveConsumerAccounts []string `json:"remove_consumer_accounts"`

	// Consumer IP ranges or CIDRs to be removed from accessing the HVD cluster associated with the private_link service.
	RemoveConsumerIPRanges []string `json:"remove_consumer_ip_ranges"`

	// Consumer cloud provider regions to remove from the private_link service
	RemoveConsumerRegions []string `json:"remove_consumer_regions"`
}

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

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

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

func (m *HashicorpCloudNetwork20200907UpdatePrivateLinkServiceRequest) 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
}

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

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

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

func (m *HashicorpCloudNetwork20200907UpdatePrivateLinkServiceRequest) 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
}

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

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