{-# 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.EC2.Types.VpcAttachment
-- 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.EC2.Types.VpcAttachment where

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

-- | Describes an attachment between a virtual private gateway and a VPC.
--
-- /See:/ 'newVpcAttachment' smart constructor.
data VpcAttachment = VpcAttachment'
  { -- | The current state of the attachment.
    VpcAttachment -> Maybe AttachmentStatus
state :: Prelude.Maybe AttachmentStatus,
    -- | The ID of the VPC.
    VpcAttachment -> Maybe Text
vpcId :: Prelude.Maybe Prelude.Text
  }
  deriving (VpcAttachment -> VpcAttachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VpcAttachment -> VpcAttachment -> Bool
$c/= :: VpcAttachment -> VpcAttachment -> Bool
== :: VpcAttachment -> VpcAttachment -> Bool
$c== :: VpcAttachment -> VpcAttachment -> Bool
Prelude.Eq, ReadPrec [VpcAttachment]
ReadPrec VpcAttachment
Int -> ReadS VpcAttachment
ReadS [VpcAttachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VpcAttachment]
$creadListPrec :: ReadPrec [VpcAttachment]
readPrec :: ReadPrec VpcAttachment
$creadPrec :: ReadPrec VpcAttachment
readList :: ReadS [VpcAttachment]
$creadList :: ReadS [VpcAttachment]
readsPrec :: Int -> ReadS VpcAttachment
$creadsPrec :: Int -> ReadS VpcAttachment
Prelude.Read, Int -> VpcAttachment -> ShowS
[VpcAttachment] -> ShowS
VpcAttachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VpcAttachment] -> ShowS
$cshowList :: [VpcAttachment] -> ShowS
show :: VpcAttachment -> String
$cshow :: VpcAttachment -> String
showsPrec :: Int -> VpcAttachment -> ShowS
$cshowsPrec :: Int -> VpcAttachment -> ShowS
Prelude.Show, forall x. Rep VpcAttachment x -> VpcAttachment
forall x. VpcAttachment -> Rep VpcAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VpcAttachment x -> VpcAttachment
$cfrom :: forall x. VpcAttachment -> Rep VpcAttachment x
Prelude.Generic)

-- |
-- Create a value of 'VpcAttachment' 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:
--
-- 'state', 'vpcAttachment_state' - The current state of the attachment.
--
-- 'vpcId', 'vpcAttachment_vpcId' - The ID of the VPC.
newVpcAttachment ::
  VpcAttachment
newVpcAttachment :: VpcAttachment
newVpcAttachment =
  VpcAttachment'
    { $sel:state:VpcAttachment' :: Maybe AttachmentStatus
state = forall a. Maybe a
Prelude.Nothing,
      $sel:vpcId:VpcAttachment' :: Maybe Text
vpcId = forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the attachment.
vpcAttachment_state :: Lens.Lens' VpcAttachment (Prelude.Maybe AttachmentStatus)
vpcAttachment_state :: Lens' VpcAttachment (Maybe AttachmentStatus)
vpcAttachment_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VpcAttachment' {Maybe AttachmentStatus
state :: Maybe AttachmentStatus
$sel:state:VpcAttachment' :: VpcAttachment -> Maybe AttachmentStatus
state} -> Maybe AttachmentStatus
state) (\s :: VpcAttachment
s@VpcAttachment' {} Maybe AttachmentStatus
a -> VpcAttachment
s {$sel:state:VpcAttachment' :: Maybe AttachmentStatus
state = Maybe AttachmentStatus
a} :: VpcAttachment)

-- | The ID of the VPC.
vpcAttachment_vpcId :: Lens.Lens' VpcAttachment (Prelude.Maybe Prelude.Text)
vpcAttachment_vpcId :: Lens' VpcAttachment (Maybe Text)
vpcAttachment_vpcId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VpcAttachment' {Maybe Text
vpcId :: Maybe Text
$sel:vpcId:VpcAttachment' :: VpcAttachment -> Maybe Text
vpcId} -> Maybe Text
vpcId) (\s :: VpcAttachment
s@VpcAttachment' {} Maybe Text
a -> VpcAttachment
s {$sel:vpcId:VpcAttachment' :: Maybe Text
vpcId = Maybe Text
a} :: VpcAttachment)

instance Data.FromXML VpcAttachment where
  parseXML :: [Node] -> Either String VpcAttachment
parseXML [Node]
x =
    Maybe AttachmentStatus -> Maybe Text -> VpcAttachment
VpcAttachment'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"state")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"vpcId")

instance Prelude.Hashable VpcAttachment where
  hashWithSalt :: Int -> VpcAttachment -> Int
hashWithSalt Int
_salt VpcAttachment' {Maybe Text
Maybe AttachmentStatus
vpcId :: Maybe Text
state :: Maybe AttachmentStatus
$sel:vpcId:VpcAttachment' :: VpcAttachment -> Maybe Text
$sel:state:VpcAttachment' :: VpcAttachment -> Maybe AttachmentStatus
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttachmentStatus
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
vpcId

instance Prelude.NFData VpcAttachment where
  rnf :: VpcAttachment -> ()
rnf VpcAttachment' {Maybe Text
Maybe AttachmentStatus
vpcId :: Maybe Text
state :: Maybe AttachmentStatus
$sel:vpcId:VpcAttachment' :: VpcAttachment -> Maybe Text
$sel:state:VpcAttachment' :: VpcAttachment -> Maybe AttachmentStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttachmentStatus
state seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
vpcId