{-# 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.ImageBuilder.Types.Ami
-- 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.ImageBuilder.Types.Ami where

import qualified Amazonka.Core as Core
import Amazonka.ImageBuilder.Types.ImageState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details of an Amazon EC2 AMI.
--
-- /See:/ 'newAmi' smart constructor.
data Ami = Ami'
  { -- | The AMI ID of the Amazon EC2 AMI.
    Ami -> Maybe Text
image :: Prelude.Maybe Prelude.Text,
    Ami -> Maybe ImageState
state :: Prelude.Maybe ImageState,
    -- | The account ID of the owner of the AMI.
    Ami -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon EC2 AMI.
    Ami -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region of the Amazon EC2 AMI.
    Ami -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The description of the Amazon EC2 AMI. Minimum and maximum length are in
    -- characters.
    Ami -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (Ami -> Ami -> Bool
(Ami -> Ami -> Bool) -> (Ami -> Ami -> Bool) -> Eq Ami
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ami -> Ami -> Bool
$c/= :: Ami -> Ami -> Bool
== :: Ami -> Ami -> Bool
$c== :: Ami -> Ami -> Bool
Prelude.Eq, ReadPrec [Ami]
ReadPrec Ami
Int -> ReadS Ami
ReadS [Ami]
(Int -> ReadS Ami)
-> ReadS [Ami] -> ReadPrec Ami -> ReadPrec [Ami] -> Read Ami
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ami]
$creadListPrec :: ReadPrec [Ami]
readPrec :: ReadPrec Ami
$creadPrec :: ReadPrec Ami
readList :: ReadS [Ami]
$creadList :: ReadS [Ami]
readsPrec :: Int -> ReadS Ami
$creadsPrec :: Int -> ReadS Ami
Prelude.Read, Int -> Ami -> ShowS
[Ami] -> ShowS
Ami -> String
(Int -> Ami -> ShowS)
-> (Ami -> String) -> ([Ami] -> ShowS) -> Show Ami
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ami] -> ShowS
$cshowList :: [Ami] -> ShowS
show :: Ami -> String
$cshow :: Ami -> String
showsPrec :: Int -> Ami -> ShowS
$cshowsPrec :: Int -> Ami -> ShowS
Prelude.Show, (forall x. Ami -> Rep Ami x)
-> (forall x. Rep Ami x -> Ami) -> Generic Ami
forall x. Rep Ami x -> Ami
forall x. Ami -> Rep Ami x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ami x -> Ami
$cfrom :: forall x. Ami -> Rep Ami x
Prelude.Generic)

-- |
-- Create a value of 'Ami' 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:
--
-- 'image', 'ami_image' - The AMI ID of the Amazon EC2 AMI.
--
-- 'state', 'ami_state' - Undocumented member.
--
-- 'accountId', 'ami_accountId' - The account ID of the owner of the AMI.
--
-- 'name', 'ami_name' - The name of the Amazon EC2 AMI.
--
-- 'region', 'ami_region' - The Amazon Web Services Region of the Amazon EC2 AMI.
--
-- 'description', 'ami_description' - The description of the Amazon EC2 AMI. Minimum and maximum length are in
-- characters.
newAmi ::
  Ami
newAmi :: Ami
newAmi =
  Ami' :: Maybe Text
-> Maybe ImageState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Ami
Ami'
    { $sel:image:Ami' :: Maybe Text
image = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Ami' :: Maybe ImageState
state = Maybe ImageState
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:Ami' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Ami' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:Ami' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Ami' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The AMI ID of the Amazon EC2 AMI.
ami_image :: Lens.Lens' Ami (Prelude.Maybe Prelude.Text)
ami_image :: (Maybe Text -> f (Maybe Text)) -> Ami -> f Ami
ami_image = (Ami -> Maybe Text)
-> (Ami -> Maybe Text -> Ami)
-> Lens Ami Ami (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe Text
image :: Maybe Text
$sel:image:Ami' :: Ami -> Maybe Text
image} -> Maybe Text
image) (\s :: Ami
s@Ami' {} Maybe Text
a -> Ami
s {$sel:image:Ami' :: Maybe Text
image = Maybe Text
a} :: Ami)

-- | Undocumented member.
ami_state :: Lens.Lens' Ami (Prelude.Maybe ImageState)
ami_state :: (Maybe ImageState -> f (Maybe ImageState)) -> Ami -> f Ami
ami_state = (Ami -> Maybe ImageState)
-> (Ami -> Maybe ImageState -> Ami)
-> Lens Ami Ami (Maybe ImageState) (Maybe ImageState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe ImageState
state :: Maybe ImageState
$sel:state:Ami' :: Ami -> Maybe ImageState
state} -> Maybe ImageState
state) (\s :: Ami
s@Ami' {} Maybe ImageState
a -> Ami
s {$sel:state:Ami' :: Maybe ImageState
state = Maybe ImageState
a} :: Ami)

-- | The account ID of the owner of the AMI.
ami_accountId :: Lens.Lens' Ami (Prelude.Maybe Prelude.Text)
ami_accountId :: (Maybe Text -> f (Maybe Text)) -> Ami -> f Ami
ami_accountId = (Ami -> Maybe Text)
-> (Ami -> Maybe Text -> Ami)
-> Lens Ami Ami (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe Text
accountId :: Maybe Text
$sel:accountId:Ami' :: Ami -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: Ami
s@Ami' {} Maybe Text
a -> Ami
s {$sel:accountId:Ami' :: Maybe Text
accountId = Maybe Text
a} :: Ami)

-- | The name of the Amazon EC2 AMI.
ami_name :: Lens.Lens' Ami (Prelude.Maybe Prelude.Text)
ami_name :: (Maybe Text -> f (Maybe Text)) -> Ami -> f Ami
ami_name = (Ami -> Maybe Text)
-> (Ami -> Maybe Text -> Ami)
-> Lens Ami Ami (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe Text
name :: Maybe Text
$sel:name:Ami' :: Ami -> Maybe Text
name} -> Maybe Text
name) (\s :: Ami
s@Ami' {} Maybe Text
a -> Ami
s {$sel:name:Ami' :: Maybe Text
name = Maybe Text
a} :: Ami)

-- | The Amazon Web Services Region of the Amazon EC2 AMI.
ami_region :: Lens.Lens' Ami (Prelude.Maybe Prelude.Text)
ami_region :: (Maybe Text -> f (Maybe Text)) -> Ami -> f Ami
ami_region = (Ami -> Maybe Text)
-> (Ami -> Maybe Text -> Ami)
-> Lens Ami Ami (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe Text
region :: Maybe Text
$sel:region:Ami' :: Ami -> Maybe Text
region} -> Maybe Text
region) (\s :: Ami
s@Ami' {} Maybe Text
a -> Ami
s {$sel:region:Ami' :: Maybe Text
region = Maybe Text
a} :: Ami)

-- | The description of the Amazon EC2 AMI. Minimum and maximum length are in
-- characters.
ami_description :: Lens.Lens' Ami (Prelude.Maybe Prelude.Text)
ami_description :: (Maybe Text -> f (Maybe Text)) -> Ami -> f Ami
ami_description = (Ami -> Maybe Text)
-> (Ami -> Maybe Text -> Ami)
-> Lens Ami Ami (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ami' {Maybe Text
description :: Maybe Text
$sel:description:Ami' :: Ami -> Maybe Text
description} -> Maybe Text
description) (\s :: Ami
s@Ami' {} Maybe Text
a -> Ami
s {$sel:description:Ami' :: Maybe Text
description = Maybe Text
a} :: Ami)

instance Core.FromJSON Ami where
  parseJSON :: Value -> Parser Ami
parseJSON =
    String -> (Object -> Parser Ami) -> Value -> Parser Ami
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Ami"
      ( \Object
x ->
          Maybe Text
-> Maybe ImageState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Ami
Ami'
            (Maybe Text
 -> Maybe ImageState
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Ami)
-> Parser (Maybe Text)
-> Parser
     (Maybe ImageState
      -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Ami)
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
"image")
            Parser
  (Maybe ImageState
   -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Ami)
-> Parser (Maybe ImageState)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Ami)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ImageState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Ami)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Ami)
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
"accountId")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Ami)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Maybe Text -> Ami)
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
"name")
            Parser (Maybe Text -> Maybe Text -> Ami)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Ami)
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
"region")
            Parser (Maybe Text -> Ami) -> Parser (Maybe Text) -> Parser Ami
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
"description")
      )

instance Prelude.Hashable Ami

instance Prelude.NFData Ami