{-# 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.Snowball.Types.Ec2AmiResource
-- 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.Snowball.Types.Ec2AmiResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A JSON-formatted object that contains the IDs for an Amazon Machine
-- Image (AMI), including the Amazon EC2 AMI ID and the Snow device AMI ID.
-- Each AMI has these two IDs to simplify identifying the AMI in both the
-- AWS Cloud and on the device.
--
-- /See:/ 'newEc2AmiResource' smart constructor.
data Ec2AmiResource = Ec2AmiResource'
  { -- | The ID of the AMI on the Snow device.
    Ec2AmiResource -> Maybe Text
snowballAmiId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the AMI in Amazon EC2.
    Ec2AmiResource -> Text
amiId :: Prelude.Text
  }
  deriving (Ec2AmiResource -> Ec2AmiResource -> Bool
(Ec2AmiResource -> Ec2AmiResource -> Bool)
-> (Ec2AmiResource -> Ec2AmiResource -> Bool) -> Eq Ec2AmiResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ec2AmiResource -> Ec2AmiResource -> Bool
$c/= :: Ec2AmiResource -> Ec2AmiResource -> Bool
== :: Ec2AmiResource -> Ec2AmiResource -> Bool
$c== :: Ec2AmiResource -> Ec2AmiResource -> Bool
Prelude.Eq, ReadPrec [Ec2AmiResource]
ReadPrec Ec2AmiResource
Int -> ReadS Ec2AmiResource
ReadS [Ec2AmiResource]
(Int -> ReadS Ec2AmiResource)
-> ReadS [Ec2AmiResource]
-> ReadPrec Ec2AmiResource
-> ReadPrec [Ec2AmiResource]
-> Read Ec2AmiResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ec2AmiResource]
$creadListPrec :: ReadPrec [Ec2AmiResource]
readPrec :: ReadPrec Ec2AmiResource
$creadPrec :: ReadPrec Ec2AmiResource
readList :: ReadS [Ec2AmiResource]
$creadList :: ReadS [Ec2AmiResource]
readsPrec :: Int -> ReadS Ec2AmiResource
$creadsPrec :: Int -> ReadS Ec2AmiResource
Prelude.Read, Int -> Ec2AmiResource -> ShowS
[Ec2AmiResource] -> ShowS
Ec2AmiResource -> String
(Int -> Ec2AmiResource -> ShowS)
-> (Ec2AmiResource -> String)
-> ([Ec2AmiResource] -> ShowS)
-> Show Ec2AmiResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ec2AmiResource] -> ShowS
$cshowList :: [Ec2AmiResource] -> ShowS
show :: Ec2AmiResource -> String
$cshow :: Ec2AmiResource -> String
showsPrec :: Int -> Ec2AmiResource -> ShowS
$cshowsPrec :: Int -> Ec2AmiResource -> ShowS
Prelude.Show, (forall x. Ec2AmiResource -> Rep Ec2AmiResource x)
-> (forall x. Rep Ec2AmiResource x -> Ec2AmiResource)
-> Generic Ec2AmiResource
forall x. Rep Ec2AmiResource x -> Ec2AmiResource
forall x. Ec2AmiResource -> Rep Ec2AmiResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ec2AmiResource x -> Ec2AmiResource
$cfrom :: forall x. Ec2AmiResource -> Rep Ec2AmiResource x
Prelude.Generic)

-- |
-- Create a value of 'Ec2AmiResource' 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:
--
-- 'snowballAmiId', 'ec2AmiResource_snowballAmiId' - The ID of the AMI on the Snow device.
--
-- 'amiId', 'ec2AmiResource_amiId' - The ID of the AMI in Amazon EC2.
newEc2AmiResource ::
  -- | 'amiId'
  Prelude.Text ->
  Ec2AmiResource
newEc2AmiResource :: Text -> Ec2AmiResource
newEc2AmiResource Text
pAmiId_ =
  Ec2AmiResource' :: Maybe Text -> Text -> Ec2AmiResource
Ec2AmiResource'
    { $sel:snowballAmiId:Ec2AmiResource' :: Maybe Text
snowballAmiId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:amiId:Ec2AmiResource' :: Text
amiId = Text
pAmiId_
    }

-- | The ID of the AMI on the Snow device.
ec2AmiResource_snowballAmiId :: Lens.Lens' Ec2AmiResource (Prelude.Maybe Prelude.Text)
ec2AmiResource_snowballAmiId :: (Maybe Text -> f (Maybe Text))
-> Ec2AmiResource -> f Ec2AmiResource
ec2AmiResource_snowballAmiId = (Ec2AmiResource -> Maybe Text)
-> (Ec2AmiResource -> Maybe Text -> Ec2AmiResource)
-> Lens Ec2AmiResource Ec2AmiResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ec2AmiResource' {Maybe Text
snowballAmiId :: Maybe Text
$sel:snowballAmiId:Ec2AmiResource' :: Ec2AmiResource -> Maybe Text
snowballAmiId} -> Maybe Text
snowballAmiId) (\s :: Ec2AmiResource
s@Ec2AmiResource' {} Maybe Text
a -> Ec2AmiResource
s {$sel:snowballAmiId:Ec2AmiResource' :: Maybe Text
snowballAmiId = Maybe Text
a} :: Ec2AmiResource)

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

instance Core.FromJSON Ec2AmiResource where
  parseJSON :: Value -> Parser Ec2AmiResource
parseJSON =
    String
-> (Object -> Parser Ec2AmiResource)
-> Value
-> Parser Ec2AmiResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Ec2AmiResource"
      ( \Object
x ->
          Maybe Text -> Text -> Ec2AmiResource
Ec2AmiResource'
            (Maybe Text -> Text -> Ec2AmiResource)
-> Parser (Maybe Text) -> Parser (Text -> Ec2AmiResource)
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
"SnowballAmiId")
            Parser (Text -> Ec2AmiResource)
-> Parser Text -> Parser Ec2AmiResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AmiId")
      )

instance Prelude.Hashable Ec2AmiResource

instance Prelude.NFData Ec2AmiResource

instance Core.ToJSON Ec2AmiResource where
  toJSON :: Ec2AmiResource -> Value
toJSON Ec2AmiResource' {Maybe Text
Text
amiId :: Text
snowballAmiId :: Maybe Text
$sel:amiId:Ec2AmiResource' :: Ec2AmiResource -> Text
$sel:snowballAmiId:Ec2AmiResource' :: Ec2AmiResource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SnowballAmiId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snowballAmiId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AmiId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
amiId)
          ]
      )