// Code generated by smithy-go-codegen DO NOT EDIT.

package directconnect

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/directconnect/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Provisions a private virtual interface to be owned by the specified Amazon Web
// Services account.
//
// Virtual interfaces created using this action must be confirmed by the owner
// using ConfirmPrivateVirtualInterface. Until then, the virtual interface is in the Confirming state and is not
// available to handle traffic.
func (c *Client) AllocatePrivateVirtualInterface(ctx context.Context, params *AllocatePrivateVirtualInterfaceInput, optFns ...func(*Options)) (*AllocatePrivateVirtualInterfaceOutput, error) {
	if params == nil {
		params = &AllocatePrivateVirtualInterfaceInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "AllocatePrivateVirtualInterface", params, optFns, c.addOperationAllocatePrivateVirtualInterfaceMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*AllocatePrivateVirtualInterfaceOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type AllocatePrivateVirtualInterfaceInput struct {

	// The ID of the connection on which the private virtual interface is provisioned.
	//
	// This member is required.
	ConnectionId *string

	// Information about the private virtual interface.
	//
	// This member is required.
	NewPrivateVirtualInterfaceAllocation *types.NewPrivateVirtualInterfaceAllocation

	// The ID of the Amazon Web Services account that owns the virtual private
	// interface.
	//
	// This member is required.
	OwnerAccount *string

	noSmithyDocumentSerde
}

// Information about a virtual interface.
type AllocatePrivateVirtualInterfaceOutput struct {

	// The address family for the BGP peer.
	AddressFamily types.AddressFamily

	// The IP address assigned to the Amazon interface.
	AmazonAddress *string

	// The autonomous system number (AS) for the Amazon side of the connection.
	AmazonSideAsn *int64

	// The autonomous system number (ASN). The valid range is from 1 to 2147483646 for
	// Border Gateway Protocol (BGP) configuration. If you provide a number greater
	// than the maximum, an error is returned. Use asnLong instead.
	//
	//   - You can use asnLong or asn , but not both. We recommend using asnLong as it
	//   supports a greater pool of numbers.
	//
	//   - If you provide a value in the same API call for both asn and asnLong , the
	//   API will only accept the value for asnLong .
	//
	//   - If you enter a 4-byte ASN for the asn parameter, the API returns an error.
	//
	//   - If you are using a 2-byte ASN, the API response will include the 2-byte
	//   value for both the asn and asnLong fields.
	Asn int32

	// The long ASN for the virtual interface. The valid range is from 1 to 4294967294
	// for BGP configuration.
	//
	// Note the following limitations when using asnLong :
	//
	//   - You can use asnLong or asn , but not both. We recommend using asnLong as it
	//   supports a greater pool of numbers.
	//
	//   - asnLong accepts any valid ASN value, regardless if it's 2-byte or 4-byte.
	//
	//   - When using a 4-byte asnLong , the API response returns 0 for the legacy asn
	//   attribute since 4-byte ASN values exceed the maximum supported value of
	//   2,147,483,647.
	//
	//   - If you are using a 2-byte ASN, the API response will include the 2-byte
	//   value for both the asn and asnLong fields.
	//
	//   - If you provide a value in the same API call for both asn and asnLong , the
	//   API will only accept the value for asnLong .
	AsnLong *int64

	// The authentication key for BGP configuration. This string has a minimum length
	// of 6 characters and and a maximun lenth of 80 characters.
	AuthKey *string

	// The Direct Connect endpoint that terminates the physical connection.
	AwsDeviceV2 *string

	// The Direct Connect endpoint that terminates the logical connection. This device
	// might be different than the device that terminates the physical connection.
	AwsLogicalDeviceId *string

	// The BGP peers configured on this virtual interface.
	BgpPeers []types.BGPPeer

	// The ID of the connection.
	ConnectionId *string

	// The IP address assigned to the customer interface.
	CustomerAddress *string

	// The customer router configuration.
	CustomerRouterConfig *string

	// The ID of the Direct Connect gateway.
	DirectConnectGatewayId *string

	// Indicates whether jumbo frames are supported.
	JumboFrameCapable *bool

	// The location of the connection.
	Location *string

	// The maximum transmission unit (MTU), in bytes. The supported values are 1500
	// and 8500. The default value is 1500
	Mtu *int32

	// The ID of the Amazon Web Services account that owns the virtual interface.
	OwnerAccount *string

	// The rate limit (bandwidth allocation) applied to the virtual interface. The
	// value must be one of the supported bandwidth values and cannot exceed the
	// bandwidth of the parent connection or LAG. Supported values: 50Mbps , 100Mbps ,
	// 200Mbps , 300Mbps , 400Mbps , 500Mbps , 600Mbps , 700Mbps , 800Mbps , 900Mbps ,
	// 1Gbps , 1.2Gbps , 1.5Gbps , 1.8Gbps , 2Gbps , 2.1Gbps , 2.4Gbps , 2.7Gbps ,
	// 3Gbps , 3.2Gbps , 3.6Gbps , 4Gbps , 5Gbps , 6Gbps , 7Gbps , 8Gbps , 9Gbps ,
	// 10Gbps , 12Gbps , 15Gbps , 18Gbps , 20Gbps , 21Gbps , 24Gbps , 27Gbps , 30Gbps ,
	// 32Gbps , 36Gbps , 40Gbps , 50Gbps , 60Gbps , 70Gbps , 80Gbps , 100Gbps , 120Gbps
	// , 150Gbps , 180Gbps , 200Gbps , 210Gbps , 240Gbps , 270Gbps , 300Gbps , 320Gbps
	// , 360Gbps , 400Gbps , 450Gbps , 480Gbps , 500Gbps , 540Gbps , 600Gbps , 700Gbps
	// , 800Gbps , 900Gbps , 1Tbps , 1.1Tbps , 1.2Tbps , 1.3Tbps , 1.4Tbps , 1.5Tbps ,
	// 1.6Tbps .
	RateLimit *string

	// The Amazon Web Services Region where the virtual interface is located.
	Region *string

	// The routes to be advertised to the Amazon Web Services network in this Region.
	// Applies to public virtual interfaces.
	RouteFilterPrefixes []types.RouteFilterPrefix

	// Indicates whether SiteLink is enabled.
	SiteLinkEnabled *bool

	// The tags associated with the virtual interface.
	Tags []types.Tag

	// The ID of the virtual private gateway. Applies only to private virtual
	// interfaces.
	VirtualGatewayId *string

	// The ID of the virtual interface.
	VirtualInterfaceId *string

	// The name of the virtual interface assigned by the customer network. The name
	// has a maximum of 100 characters. The following are valid characters: a-z, 0-9
	// and a hyphen (-).
	VirtualInterfaceName *string

	// The state of the virtual interface. The following are the possible values:
	//
	//   - confirming : The creation of the virtual interface is pending confirmation
	//   from the virtual interface owner. If the owner of the virtual interface is
	//   different from the owner of the connection on which it is provisioned, then the
	//   virtual interface will remain in this state until it is confirmed by the virtual
	//   interface owner.
	//
	//   - verifying : This state only applies to public virtual interfaces. Each
	//   public virtual interface needs validation before the virtual interface can be
	//   created.
	//
	//   - pending : A virtual interface is in this state from the time that it is
	//   created until the virtual interface is ready to forward traffic.
	//
	//   - available : A virtual interface that is able to forward traffic.
	//
	//   - down : A virtual interface that is BGP down.
	//
	//   - testing : A virtual interface is in this state immediately after calling StartBgpFailoverTest
	//   and remains in this state during the duration of the test.
	//
	//   - deleting : A virtual interface is in this state immediately after calling DeleteVirtualInterface
	//   until it can no longer forward traffic.
	//
	//   - deleted : A virtual interface that cannot forward traffic.
	//
	//   - rejected : The virtual interface owner has declined creation of the virtual
	//   interface. If a virtual interface in the Confirming state is deleted by the
	//   virtual interface owner, the virtual interface enters the Rejected state.
	//
	//   - unknown : The state of the virtual interface is not available.
	VirtualInterfaceState types.VirtualInterfaceState

	// The type of virtual interface. The possible values are private , public and
	// transit .
	VirtualInterfaceType *string

	// The ID of the VLAN.
	Vlan int32

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationAllocatePrivateVirtualInterfaceMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpAllocatePrivateVirtualInterface{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAllocatePrivateVirtualInterface{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpAllocatePrivateVirtualInterfaceValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "AllocatePrivateVirtualInterface"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
