{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Snowball.Types.Ec2AmiResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
-- Amazon Web Services 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
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]
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
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. 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'
    { $sel:snowballAmiId:Ec2AmiResource' :: Maybe Text
snowballAmiId = 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 :: Lens' Ec2AmiResource (Maybe Text)
ec2AmiResource_snowballAmiId = 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 :: Lens' Ec2AmiResource Text
ec2AmiResource_amiId = 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 Data.FromJSON Ec2AmiResource where
  parseJSON :: Value -> Parser Ec2AmiResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Ec2AmiResource"
      ( \Object
x ->
          Maybe Text -> Text -> Ec2AmiResource
Ec2AmiResource'
            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
"SnowballAmiId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AmiId")
      )

instance Prelude.Hashable Ec2AmiResource where
  hashWithSalt :: Int -> Ec2AmiResource -> Int
hashWithSalt Int
_salt Ec2AmiResource' {Maybe Text
Text
amiId :: Text
snowballAmiId :: Maybe Text
$sel:amiId:Ec2AmiResource' :: Ec2AmiResource -> Text
$sel:snowballAmiId:Ec2AmiResource' :: Ec2AmiResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snowballAmiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
amiId

instance Prelude.NFData Ec2AmiResource where
  rnf :: Ec2AmiResource -> ()
rnf Ec2AmiResource' {Maybe Text
Text
amiId :: Text
snowballAmiId :: Maybe Text
$sel:amiId:Ec2AmiResource' :: Ec2AmiResource -> Text
$sel:snowballAmiId:Ec2AmiResource' :: Ec2AmiResource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snowballAmiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
amiId

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SnowballAmiId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snowballAmiId,
            forall a. a -> Maybe a
Prelude.Just (Key
"AmiId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
amiId)
          ]
      )