{-# 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.ECS.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.ECS.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.ECS.Types.KeyValuePair
import qualified Amazonka.Prelude as Prelude

-- | An object representing a container instance or task attachment.
--
-- /See:/ 'newAttachment' smart constructor.
data Attachment = Attachment'
  { -- | Details of the attachment. For elastic network interfaces, this includes
    -- the network interface ID, the MAC address, the subnet ID, and the
    -- private IPv4 address.
    Attachment -> Maybe [KeyValuePair]
details :: Prelude.Maybe [KeyValuePair],
    -- | The unique identifier for the attachment.
    Attachment -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
    -- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, @DELETED@, and
    -- @FAILED@.
    Attachment -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The type of the attachment, such as @ElasticNetworkInterface@.
    Attachment -> Maybe Text
type' :: 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:
--
-- 'details', 'attachment_details' - Details of the attachment. For elastic network interfaces, this includes
-- the network interface ID, the MAC address, the subnet ID, and the
-- private IPv4 address.
--
-- 'id', 'attachment_id' - The unique identifier for the attachment.
--
-- 'status', 'attachment_status' - The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
-- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, @DELETED@, and
-- @FAILED@.
--
-- 'type'', 'attachment_type' - The type of the attachment, such as @ElasticNetworkInterface@.
newAttachment ::
  Attachment
newAttachment :: Attachment
newAttachment =
  Attachment'
    { $sel:details:Attachment' :: Maybe [KeyValuePair]
details = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Attachment' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Attachment' :: Maybe Text
status = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Attachment' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Details of the attachment. For elastic network interfaces, this includes
-- the network interface ID, the MAC address, the subnet ID, and the
-- private IPv4 address.
attachment_details :: Lens.Lens' Attachment (Prelude.Maybe [KeyValuePair])
attachment_details :: Lens' Attachment (Maybe [KeyValuePair])
attachment_details = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe [KeyValuePair]
details :: Maybe [KeyValuePair]
$sel:details:Attachment' :: Attachment -> Maybe [KeyValuePair]
details} -> Maybe [KeyValuePair]
details) (\s :: Attachment
s@Attachment' {} Maybe [KeyValuePair]
a -> Attachment
s {$sel:details:Attachment' :: Maybe [KeyValuePair]
details = Maybe [KeyValuePair]
a} :: Attachment) 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 unique identifier for the attachment.
attachment_id :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_id :: Lens' Attachment (Maybe Text)
attachment_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
id :: Maybe Text
$sel:id:Attachment' :: Attachment -> Maybe Text
id} -> Maybe Text
id) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:id:Attachment' :: Maybe Text
id = Maybe Text
a} :: Attachment)

-- | The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
-- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, @DELETED@, and
-- @FAILED@.
attachment_status :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_status :: Lens' Attachment (Maybe Text)
attachment_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
status :: Maybe Text
$sel:status:Attachment' :: Attachment -> Maybe Text
status} -> Maybe Text
status) (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:status:Attachment' :: Maybe Text
status = Maybe Text
a} :: Attachment)

-- | The type of the attachment, such as @ElasticNetworkInterface@.
attachment_type :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_type :: Lens' Attachment (Maybe Text)
attachment_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attachment' {Maybe Text
type' :: Maybe Text
$sel:type':Attachment' :: Attachment -> Maybe Text
type'} -> Maybe Text
type') (\s :: Attachment
s@Attachment' {} Maybe Text
a -> Attachment
s {$sel:type':Attachment' :: Maybe Text
type' = 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 [KeyValuePair]
-> Maybe Text -> 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
"details" 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
"id")
            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
"type")
      )

instance Prelude.Hashable Attachment where
  hashWithSalt :: Int -> Attachment -> Int
hashWithSalt Int
_salt Attachment' {Maybe [KeyValuePair]
Maybe Text
type' :: Maybe Text
status :: Maybe Text
id :: Maybe Text
details :: Maybe [KeyValuePair]
$sel:type':Attachment' :: Attachment -> Maybe Text
$sel:status:Attachment' :: Attachment -> Maybe Text
$sel:id:Attachment' :: Attachment -> Maybe Text
$sel:details:Attachment' :: Attachment -> Maybe [KeyValuePair]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [KeyValuePair]
details
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Attachment where
  rnf :: Attachment -> ()
rnf Attachment' {Maybe [KeyValuePair]
Maybe Text
type' :: Maybe Text
status :: Maybe Text
id :: Maybe Text
details :: Maybe [KeyValuePair]
$sel:type':Attachment' :: Attachment -> Maybe Text
$sel:status:Attachment' :: Attachment -> Maybe Text
$sel:id:Attachment' :: Attachment -> Maybe Text
$sel:details:Attachment' :: Attachment -> Maybe [KeyValuePair]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [KeyValuePair]
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'