{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Transfer.Types.EndpointDetails
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Transfer.Types.EndpointDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The virtual private cloud (VPC) endpoint settings that are configured
-- for your file transfer protocol-enabled server. With a VPC endpoint, you
-- can restrict access to your server and resources only within your VPC.
-- To control incoming internet traffic, invoke the @UpdateServer@ API and
-- attach an Elastic IP address to your server\'s endpoint.
--
-- After May 19, 2021, you won\'t be able to create a server using
-- @EndpointType=VPC_ENDPOINT@ in your Amazon Web Servicesaccount if your
-- account hasn\'t already done so before May 19, 2021. If you have already
-- created servers with @EndpointType=VPC_ENDPOINT@ in your Amazon Web
-- Servicesaccount on or before May 19, 2021, you will not be affected.
-- After this date, use @EndpointType@=@VPC@.
--
-- For more information, see
-- https:\/\/docs.aws.amazon.com\/transfer\/latest\/userguide\/create-server-in-vpc.html#deprecate-vpc-endpoint.
--
-- /See:/ 'newEndpointDetails' smart constructor.
data EndpointDetails = EndpointDetails'
  { -- | A list of address allocation IDs that are required to attach an Elastic
    -- IP address to your server\'s endpoint.
    --
    -- This property can only be set when @EndpointType@ is set to @VPC@ and it
    -- is only valid in the @UpdateServer@ API.
    EndpointDetails -> Maybe [Text]
addressAllocationIds :: Prelude.Maybe [Prelude.Text],
    -- | A list of security groups IDs that are available to attach to your
    -- server\'s endpoint.
    --
    -- This property can only be set when @EndpointType@ is set to @VPC@.
    --
    -- You can edit the @SecurityGroupIds@ property in the
    -- <https://docs.aws.amazon.com/transfer/latest/userguide/API_UpdateServer.html UpdateServer>
    -- API only if you are changing the @EndpointType@ from @PUBLIC@ or
    -- @VPC_ENDPOINT@ to @VPC@. To change security groups associated with your
    -- server\'s VPC endpoint after creation, use the Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVpcEndpoint.html ModifyVpcEndpoint>
    -- API.
    EndpointDetails -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | A list of subnet IDs that are required to host your server endpoint in
    -- your VPC.
    --
    -- This property can only be set when @EndpointType@ is set to @VPC@.
    EndpointDetails -> Maybe [Text]
subnetIds :: Prelude.Maybe [Prelude.Text],
    -- | The identifier of the VPC endpoint.
    --
    -- This property can only be set when @EndpointType@ is set to
    -- @VPC_ENDPOINT@.
    --
    -- For more information, see
    -- https:\/\/docs.aws.amazon.com\/transfer\/latest\/userguide\/create-server-in-vpc.html#deprecate-vpc-endpoint.
    EndpointDetails -> Maybe Text
vpcEndpointId :: Prelude.Maybe Prelude.Text,
    -- | The VPC identifier of the VPC in which a server\'s endpoint will be
    -- hosted.
    --
    -- This property can only be set when @EndpointType@ is set to @VPC@.
    EndpointDetails -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (EndpointDetails -> EndpointDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointDetails -> EndpointDetails -> Bool
$c/= :: EndpointDetails -> EndpointDetails -> Bool
== :: EndpointDetails -> EndpointDetails -> Bool
$c== :: EndpointDetails -> EndpointDetails -> Bool
Prelude.Eq, ReadPrec [EndpointDetails]
ReadPrec EndpointDetails
Int -> ReadS EndpointDetails
ReadS [EndpointDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointDetails]
$creadListPrec :: ReadPrec [EndpointDetails]
readPrec :: ReadPrec EndpointDetails
$creadPrec :: ReadPrec EndpointDetails
readList :: ReadS [EndpointDetails]
$creadList :: ReadS [EndpointDetails]
readsPrec :: Int -> ReadS EndpointDetails
$creadsPrec :: Int -> ReadS EndpointDetails
Prelude.Read, Int -> EndpointDetails -> ShowS
[EndpointDetails] -> ShowS
EndpointDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointDetails] -> ShowS
$cshowList :: [EndpointDetails] -> ShowS
show :: EndpointDetails -> String
$cshow :: EndpointDetails -> String
showsPrec :: Int -> EndpointDetails -> ShowS
$cshowsPrec :: Int -> EndpointDetails -> ShowS
Prelude.Show, forall x. Rep EndpointDetails x -> EndpointDetails
forall x. EndpointDetails -> Rep EndpointDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointDetails x -> EndpointDetails
$cfrom :: forall x. EndpointDetails -> Rep EndpointDetails x
Prelude.Generic)

-- |
-- Create a value of 'EndpointDetails' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'addressAllocationIds', 'endpointDetails_addressAllocationIds' - A list of address allocation IDs that are required to attach an Elastic
-- IP address to your server\'s endpoint.
--
-- This property can only be set when @EndpointType@ is set to @VPC@ and it
-- is only valid in the @UpdateServer@ API.
--
-- 'securityGroupIds', 'endpointDetails_securityGroupIds' - A list of security groups IDs that are available to attach to your
-- server\'s endpoint.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
--
-- You can edit the @SecurityGroupIds@ property in the
-- <https://docs.aws.amazon.com/transfer/latest/userguide/API_UpdateServer.html UpdateServer>
-- API only if you are changing the @EndpointType@ from @PUBLIC@ or
-- @VPC_ENDPOINT@ to @VPC@. To change security groups associated with your
-- server\'s VPC endpoint after creation, use the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVpcEndpoint.html ModifyVpcEndpoint>
-- API.
--
-- 'subnetIds', 'endpointDetails_subnetIds' - A list of subnet IDs that are required to host your server endpoint in
-- your VPC.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
--
-- 'vpcEndpointId', 'endpointDetails_vpcEndpointId' - The identifier of the VPC endpoint.
--
-- This property can only be set when @EndpointType@ is set to
-- @VPC_ENDPOINT@.
--
-- For more information, see
-- https:\/\/docs.aws.amazon.com\/transfer\/latest\/userguide\/create-server-in-vpc.html#deprecate-vpc-endpoint.
--
-- 'vpcId', 'endpointDetails_vpcId' - The VPC identifier of the VPC in which a server\'s endpoint will be
-- hosted.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
newEndpointDetails ::
  EndpointDetails
newEndpointDetails :: EndpointDetails
newEndpointDetails =
  EndpointDetails'
    { $sel:addressAllocationIds:EndpointDetails' :: Maybe [Text]
addressAllocationIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:securityGroupIds:EndpointDetails' :: Maybe [Text]
securityGroupIds = forall a. Maybe a
Prelude.Nothing,
      $sel:subnetIds:EndpointDetails' :: Maybe [Text]
subnetIds = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointId:EndpointDetails' :: Maybe Text
vpcEndpointId = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:EndpointDetails' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of address allocation IDs that are required to attach an Elastic
-- IP address to your server\'s endpoint.
--
-- This property can only be set when @EndpointType@ is set to @VPC@ and it
-- is only valid in the @UpdateServer@ API.
endpointDetails_addressAllocationIds :: Lens.Lens' EndpointDetails (Prelude.Maybe [Prelude.Text])
endpointDetails_addressAllocationIds :: Lens' EndpointDetails (Maybe [Text])
endpointDetails_addressAllocationIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDetails' {Maybe [Text]
addressAllocationIds :: Maybe [Text]
$sel:addressAllocationIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
addressAllocationIds} -> Maybe [Text]
addressAllocationIds) (\s :: EndpointDetails
s@EndpointDetails' {} Maybe [Text]
a -> EndpointDetails
s {$sel:addressAllocationIds:EndpointDetails' :: Maybe [Text]
addressAllocationIds = Maybe [Text]
a} :: EndpointDetails) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of security groups IDs that are available to attach to your
-- server\'s endpoint.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
--
-- You can edit the @SecurityGroupIds@ property in the
-- <https://docs.aws.amazon.com/transfer/latest/userguide/API_UpdateServer.html UpdateServer>
-- API only if you are changing the @EndpointType@ from @PUBLIC@ or
-- @VPC_ENDPOINT@ to @VPC@. To change security groups associated with your
-- server\'s VPC endpoint after creation, use the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyVpcEndpoint.html ModifyVpcEndpoint>
-- API.
endpointDetails_securityGroupIds :: Lens.Lens' EndpointDetails (Prelude.Maybe [Prelude.Text])
endpointDetails_securityGroupIds :: Lens' EndpointDetails (Maybe [Text])
endpointDetails_securityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDetails' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: EndpointDetails
s@EndpointDetails' {} Maybe [Text]
a -> EndpointDetails
s {$sel:securityGroupIds:EndpointDetails' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: EndpointDetails) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of subnet IDs that are required to host your server endpoint in
-- your VPC.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
endpointDetails_subnetIds :: Lens.Lens' EndpointDetails (Prelude.Maybe [Prelude.Text])
endpointDetails_subnetIds :: Lens' EndpointDetails (Maybe [Text])
endpointDetails_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDetails' {Maybe [Text]
subnetIds :: Maybe [Text]
$sel:subnetIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
subnetIds} -> Maybe [Text]
subnetIds) (\s :: EndpointDetails
s@EndpointDetails' {} Maybe [Text]
a -> EndpointDetails
s {$sel:subnetIds:EndpointDetails' :: Maybe [Text]
subnetIds = Maybe [Text]
a} :: EndpointDetails) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of the VPC endpoint.
--
-- This property can only be set when @EndpointType@ is set to
-- @VPC_ENDPOINT@.
--
-- For more information, see
-- https:\/\/docs.aws.amazon.com\/transfer\/latest\/userguide\/create-server-in-vpc.html#deprecate-vpc-endpoint.
endpointDetails_vpcEndpointId :: Lens.Lens' EndpointDetails (Prelude.Maybe Prelude.Text)
endpointDetails_vpcEndpointId :: Lens' EndpointDetails (Maybe Text)
endpointDetails_vpcEndpointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDetails' {Maybe Text
vpcEndpointId :: Maybe Text
$sel:vpcEndpointId:EndpointDetails' :: EndpointDetails -> Maybe Text
vpcEndpointId} -> Maybe Text
vpcEndpointId) (\s :: EndpointDetails
s@EndpointDetails' {} Maybe Text
a -> EndpointDetails
s {$sel:vpcEndpointId:EndpointDetails' :: Maybe Text
vpcEndpointId = Maybe Text
a} :: EndpointDetails)

-- | The VPC identifier of the VPC in which a server\'s endpoint will be
-- hosted.
--
-- This property can only be set when @EndpointType@ is set to @VPC@.
endpointDetails_vpcId :: Lens.Lens' EndpointDetails (Prelude.Maybe Prelude.Text)
endpointDetails_vpcId :: Lens' EndpointDetails (Maybe Text)
endpointDetails_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDetails' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:EndpointDetails' :: EndpointDetails -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: EndpointDetails
s@EndpointDetails' {} Maybe Text
a -> EndpointDetails
s {$sel:vpcId:EndpointDetails' :: Maybe Text
vpcId = Maybe Text
a} :: EndpointDetails)

instance Data.FromJSON EndpointDetails where
  parseJSON :: Value -> Parser EndpointDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointDetails"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> EndpointDetails
EndpointDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AddressAllocationIds"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SecurityGroupIds"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SubnetIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VpcEndpointId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VpcId")
      )

instance Prelude.Hashable EndpointDetails where
  hashWithSalt :: Int -> EndpointDetails -> Int
hashWithSalt Int
_salt EndpointDetails' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
vpcEndpointId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
addressAllocationIds :: Maybe [Text]
$sel:vpcId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:vpcEndpointId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:subnetIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:securityGroupIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:addressAllocationIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
addressAllocationIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
securityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
subnetIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcEndpointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData EndpointDetails where
  rnf :: EndpointDetails -> ()
rnf EndpointDetails' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
vpcEndpointId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
addressAllocationIds :: Maybe [Text]
$sel:vpcId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:vpcEndpointId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:subnetIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:securityGroupIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:addressAllocationIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
addressAllocationIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
securityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
subnetIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcEndpointId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId

instance Data.ToJSON EndpointDetails where
  toJSON :: EndpointDetails -> Value
toJSON EndpointDetails' {Maybe [Text]
Maybe Text
vpcId :: Maybe Text
vpcEndpointId :: Maybe Text
subnetIds :: Maybe [Text]
securityGroupIds :: Maybe [Text]
addressAllocationIds :: Maybe [Text]
$sel:vpcId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:vpcEndpointId:EndpointDetails' :: EndpointDetails -> Maybe Text
$sel:subnetIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:securityGroupIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
$sel:addressAllocationIds:EndpointDetails' :: EndpointDetails -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AddressAllocationIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
addressAllocationIds,
            (Key
"SecurityGroupIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
securityGroupIds,
            (Key
"SubnetIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
subnetIds,
            (Key
"VpcEndpointId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vpcEndpointId,
            (Key
"VpcId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vpcId
          ]
      )