{-# 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.NetworkFirewall.Types.Attachment
-- 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.NetworkFirewall.Types.Attachment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.AttachmentStatus
import qualified Amazonka.Prelude as Prelude

-- | The configuration and status for a single subnet that you\'ve specified
-- for use by the Network Firewall firewall. This is part of the
-- FirewallStatus.
--
-- /See:/ 'newAttachment' smart constructor.
data Attachment = Attachment'
  { -- | The identifier of the firewall endpoint that Network Firewall has
    -- instantiated in the subnet. You use this to identify the firewall
    -- endpoint in the VPC route tables, when you redirect the VPC traffic
    -- through the endpoint.
    Attachment -> Maybe Text
endpointId :: Prelude.Maybe Prelude.Text,
    -- | The current status of the firewall endpoint in the subnet. This value
    -- reflects both the instantiation of the endpoint in the VPC subnet and
    -- the sync states that are reported in the @Config@ settings. When this
    -- value is @READY@, the endpoint is available and configured properly to
    -- handle network traffic. When the endpoint isn\'t available for traffic,
    -- this value will reflect its state, for example @CREATING@ or @DELETING@.
    Attachment -> Maybe AttachmentStatus
status :: Prelude.Maybe AttachmentStatus,
    -- | If Network Firewall fails to create or delete the firewall endpoint in
    -- the subnet, it populates this with the reason for the failure and how to
    -- resolve it. Depending on the error, it can take as many as 15 minutes to
    -- populate this field. For more information about the errors and solutions
    -- available for this field, see
    -- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/firewall-troubleshooting-endpoint-failures.html Troubleshooting firewall endpoint failures>
    -- in the /Network Firewall Developer Guide/.
    Attachment -> Maybe Text
statusMessage :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the subnet that you\'ve specified to be used
    -- for a firewall endpoint.
    Attachment -> Maybe Text
subnetId :: Prelude.Maybe Prelude.Text
  }
  deriving (Attachment -> Attachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attachment -> Attachment -> Bool
$c/= :: Attachment -> Attachment -> Bool
== :: Attachment -> Attachment -> Bool
$c== :: Attachment -> Attachment -> Bool
Prelude.Eq, ReadPrec [Attachment]
ReadPrec Attachment
Int -> ReadS Attachment
ReadS [Attachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Attachment]
$creadListPrec :: ReadPrec [Attachment]
readPrec :: ReadPrec Attachment
$creadPrec :: ReadPrec Attachment
readList :: ReadS [Attachment]
$creadList :: ReadS [Attachment]
readsPrec :: Int -> ReadS Attachment
$creadsPrec :: Int -> ReadS Attachment
Prelude.Read, Int -> Attachment -> ShowS
[Attachment] -> ShowS
Attachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attachment] -> ShowS
$cshowList :: [Attachment] -> ShowS
show :: Attachment -> String
$cshow :: Attachment -> String
showsPrec :: Int -> Attachment -> ShowS
$cshowsPrec :: Int -> Attachment -> ShowS
Prelude.Show, forall x. Rep Attachment x -> Attachment
forall x. Attachment -> Rep Attachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attachment x -> Attachment
$cfrom :: forall x. Attachment -> Rep Attachment x
Prelude.Generic)

-- |
-- Create a value of 'Attachment' 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:
--
-- 'endpointId', 'attachment_endpointId' - The identifier of the firewall endpoint that Network Firewall has
-- instantiated in the subnet. You use this to identify the firewall
-- endpoint in the VPC route tables, when you redirect the VPC traffic
-- through the endpoint.
--
-- 'status', 'attachment_status' - The current status of the firewall endpoint in the subnet. This value
-- reflects both the instantiation of the endpoint in the VPC subnet and
-- the sync states that are reported in the @Config@ settings. When this
-- value is @READY@, the endpoint is available and configured properly to
-- handle network traffic. When the endpoint isn\'t available for traffic,
-- this value will reflect its state, for example @CREATING@ or @DELETING@.
--
-- 'statusMessage', 'attachment_statusMessage' - If Network Firewall fails to create or delete the firewall endpoint in
-- the subnet, it populates this with the reason for the failure and how to
-- resolve it. Depending on the error, it can take as many as 15 minutes to
-- populate this field. For more information about the errors and solutions
-- available for this field, see
-- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/firewall-troubleshooting-endpoint-failures.html Troubleshooting firewall endpoint failures>
-- in the /Network Firewall Developer Guide/.
--
-- 'subnetId', 'attachment_subnetId' - The unique identifier of the subnet that you\'ve specified to be used
-- for a firewall endpoint.
newAttachment ::
  Attachment
newAttachment :: Attachment
newAttachment =
  Attachment'
    { $sel:endpointId:Attachment' :: Maybe Text
endpointId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Attachment' :: Maybe AttachmentStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:statusMessage:Attachment' :: Maybe Text
statusMessage = forall a. Maybe a
Prelude.Nothing,
      $sel:subnetId:Attachment' :: Maybe Text
subnetId = forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the firewall endpoint that Network Firewall has
-- instantiated in the subnet. You use this to identify the firewall
-- endpoint in the VPC route tables, when you redirect the VPC traffic
-- through the endpoint.
attachment_endpointId :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_endpointId :: Lens' Attachment (Maybe Text)
attachment_endpointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
endpointId :: Maybe Text
$sel:endpointId:Attachment' :: Attachment -> Maybe Text
endpointId} -> Maybe Text
endpointId) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:endpointId:Attachment' :: Maybe Text
endpointId = Maybe Text
a} :: Attachment)

-- | The current status of the firewall endpoint in the subnet. This value
-- reflects both the instantiation of the endpoint in the VPC subnet and
-- the sync states that are reported in the @Config@ settings. When this
-- value is @READY@, the endpoint is available and configured properly to
-- handle network traffic. When the endpoint isn\'t available for traffic,
-- this value will reflect its state, for example @CREATING@ or @DELETING@.
attachment_status :: Lens.Lens' Attachment (Prelude.Maybe AttachmentStatus)
attachment_status :: Lens' Attachment (Maybe AttachmentStatus)
attachment_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe AttachmentStatus
status :: Maybe AttachmentStatus
$sel:status:Attachment' :: Attachment -> Maybe AttachmentStatus
status} -> Maybe AttachmentStatus
status) (\s :: Attachment
s@Attachment' {} Maybe AttachmentStatus
a -> Attachment
s {$sel:status:Attachment' :: Maybe AttachmentStatus
status = Maybe AttachmentStatus
a} :: Attachment)

-- | If Network Firewall fails to create or delete the firewall endpoint in
-- the subnet, it populates this with the reason for the failure and how to
-- resolve it. Depending on the error, it can take as many as 15 minutes to
-- populate this field. For more information about the errors and solutions
-- available for this field, see
-- <https://docs.aws.amazon.com/network-firewall/latest/developerguide/firewall-troubleshooting-endpoint-failures.html Troubleshooting firewall endpoint failures>
-- in the /Network Firewall Developer Guide/.
attachment_statusMessage :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_statusMessage :: Lens' Attachment (Maybe Text)
attachment_statusMessage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
statusMessage :: Maybe Text
$sel:statusMessage:Attachment' :: Attachment -> Maybe Text
statusMessage} -> Maybe Text
statusMessage) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:statusMessage:Attachment' :: Maybe Text
statusMessage = Maybe Text
a} :: Attachment)

-- | The unique identifier of the subnet that you\'ve specified to be used
-- for a firewall endpoint.
attachment_subnetId :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_subnetId :: Lens' Attachment (Maybe Text)
attachment_subnetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
subnetId :: Maybe Text
$sel:subnetId:Attachment' :: Attachment -> Maybe Text
subnetId} -> Maybe Text
subnetId) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:subnetId:Attachment' :: Maybe Text
subnetId = Maybe Text
a} :: Attachment)

instance Data.FromJSON Attachment where
  parseJSON :: Value -> Parser Attachment
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Attachment"
      ( \Object
x ->
          Maybe Text
-> Maybe AttachmentStatus -> Maybe Text -> Maybe Text -> Attachment
Attachment'
            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
"EndpointId")
            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
"Status")
            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
"StatusMessage")
            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
"SubnetId")
      )

instance Prelude.Hashable Attachment where
  hashWithSalt :: Int -> Attachment -> Int
hashWithSalt Int
_salt Attachment' {Maybe Text
Maybe AttachmentStatus
subnetId :: Maybe Text
statusMessage :: Maybe Text
status :: Maybe AttachmentStatus
endpointId :: Maybe Text
$sel:subnetId:Attachment' :: Attachment -> Maybe Text
$sel:statusMessage:Attachment' :: Attachment -> Maybe Text
$sel:status:Attachment' :: Attachment -> Maybe AttachmentStatus
$sel:endpointId:Attachment' :: Attachment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttachmentStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subnetId

instance Prelude.NFData Attachment where
  rnf :: Attachment -> ()
rnf Attachment' {Maybe Text
Maybe AttachmentStatus
subnetId :: Maybe Text
statusMessage :: Maybe Text
status :: Maybe AttachmentStatus
endpointId :: Maybe Text
$sel:subnetId:Attachment' :: Attachment -> Maybe Text
$sel:statusMessage:Attachment' :: Attachment -> Maybe Text
$sel:status:Attachment' :: Attachment -> Maybe AttachmentStatus
$sel:endpointId:Attachment' :: Attachment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpointId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttachmentStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subnetId