{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.Attachment where

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.KeyValuePair
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing a container instance or task attachment.
--
-- /See:/ 'newAttachment' smart constructor.
data Attachment = Attachment'
  { -- | The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
    -- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, and @DELETED@.
    Attachment -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | 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 type of the attachment, such as @ElasticNetworkInterface@.
    Attachment -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Attachment -> Attachment -> Bool
(Attachment -> Attachment -> Bool)
-> (Attachment -> Attachment -> Bool) -> Eq Attachment
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]
(Int -> ReadS Attachment)
-> ReadS [Attachment]
-> ReadPrec Attachment
-> ReadPrec [Attachment]
-> Read 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
(Int -> Attachment -> ShowS)
-> (Attachment -> String)
-> ([Attachment] -> ShowS)
-> Show Attachment
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. Attachment -> Rep Attachment x)
-> (forall x. Rep Attachment x -> Attachment) -> Generic Attachment
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:
--
-- 'status', 'attachment_status' - The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
-- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, and @DELETED@.
--
-- '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.
--
-- 'type'', 'attachment_type' - The type of the attachment, such as @ElasticNetworkInterface@.
newAttachment ::
  Attachment
newAttachment :: Attachment
newAttachment =
  Attachment' :: Maybe Text
-> Maybe [KeyValuePair] -> Maybe Text -> Maybe Text -> Attachment
Attachment'
    { $sel:status:Attachment' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:details:Attachment' :: Maybe [KeyValuePair]
details = Maybe [KeyValuePair]
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Attachment' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Attachment' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the attachment. Valid values are @PRECREATED@, @CREATED@,
-- @ATTACHING@, @ATTACHED@, @DETACHING@, @DETACHED@, and @DELETED@.
attachment_status :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_status :: (Maybe Text -> f (Maybe Text)) -> Attachment -> f Attachment
attachment_status = (Attachment -> Maybe Text)
-> (Attachment -> Maybe Text -> Attachment)
-> Lens Attachment Attachment (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe [KeyValuePair] -> f (Maybe [KeyValuePair]))
-> Attachment -> f Attachment
attachment_details = (Attachment -> Maybe [KeyValuePair])
-> (Attachment -> Maybe [KeyValuePair] -> Attachment)
-> Lens
     Attachment Attachment (Maybe [KeyValuePair]) (Maybe [KeyValuePair])
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) ((Maybe [KeyValuePair] -> f (Maybe [KeyValuePair]))
 -> Attachment -> f Attachment)
-> ((Maybe [KeyValuePair] -> f (Maybe [KeyValuePair]))
    -> Maybe [KeyValuePair] -> f (Maybe [KeyValuePair]))
-> (Maybe [KeyValuePair] -> f (Maybe [KeyValuePair]))
-> Attachment
-> f Attachment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [KeyValuePair] [KeyValuePair] [KeyValuePair] [KeyValuePair]
-> Iso
     (Maybe [KeyValuePair])
     (Maybe [KeyValuePair])
     (Maybe [KeyValuePair])
     (Maybe [KeyValuePair])
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 AnIso [KeyValuePair] [KeyValuePair] [KeyValuePair] [KeyValuePair]
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 :: (Maybe Text -> f (Maybe Text)) -> Attachment -> f Attachment
attachment_id = (Attachment -> Maybe Text)
-> (Attachment -> Maybe Text -> Attachment)
-> Lens Attachment Attachment (Maybe Text) (Maybe Text)
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 type of the attachment, such as @ElasticNetworkInterface@.
attachment_type :: Lens.Lens' Attachment (Prelude.Maybe Prelude.Text)
attachment_type :: (Maybe Text -> f (Maybe Text)) -> Attachment -> f Attachment
attachment_type = (Attachment -> Maybe Text)
-> (Attachment -> Maybe Text -> Attachment)
-> Lens Attachment Attachment (Maybe Text) (Maybe Text)
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 Core.FromJSON Attachment where
  parseJSON :: Value -> Parser Attachment
parseJSON =
    String
-> (Object -> Parser Attachment) -> Value -> Parser Attachment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Attachment"
      ( \Object
x ->
          Maybe Text
-> Maybe [KeyValuePair] -> Maybe Text -> Maybe Text -> Attachment
Attachment'
            (Maybe Text
 -> Maybe [KeyValuePair] -> Maybe Text -> Maybe Text -> Attachment)
-> Parser (Maybe Text)
-> Parser
     (Maybe [KeyValuePair] -> Maybe Text -> Maybe Text -> Attachment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe [KeyValuePair] -> Maybe Text -> Maybe Text -> Attachment)
-> Parser (Maybe [KeyValuePair])
-> Parser (Maybe Text -> Maybe Text -> Attachment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [KeyValuePair]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"details" Parser (Maybe (Maybe [KeyValuePair]))
-> Maybe [KeyValuePair] -> Parser (Maybe [KeyValuePair])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [KeyValuePair]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> Attachment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Attachment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id")
            Parser (Maybe Text -> Attachment)
-> Parser (Maybe Text) -> Parser Attachment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable Attachment

instance Prelude.NFData Attachment