{-# 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.EC2.Types.Storage
-- 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.EC2.Types.Storage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.S3Storage
import qualified Amazonka.Prelude as Prelude

-- | Describes the storage location for an instance store-backed AMI.
--
-- /See:/ 'newStorage' smart constructor.
data Storage = Storage'
  { -- | An Amazon S3 storage location.
    Storage -> Maybe S3Storage
s3 :: Prelude.Maybe S3Storage
  }
  deriving (Storage -> Storage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Storage -> Storage -> Bool
$c/= :: Storage -> Storage -> Bool
== :: Storage -> Storage -> Bool
$c== :: Storage -> Storage -> Bool
Prelude.Eq, ReadPrec [Storage]
ReadPrec Storage
Int -> ReadS Storage
ReadS [Storage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Storage]
$creadListPrec :: ReadPrec [Storage]
readPrec :: ReadPrec Storage
$creadPrec :: ReadPrec Storage
readList :: ReadS [Storage]
$creadList :: ReadS [Storage]
readsPrec :: Int -> ReadS Storage
$creadsPrec :: Int -> ReadS Storage
Prelude.Read, Int -> Storage -> ShowS
[Storage] -> ShowS
Storage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Storage] -> ShowS
$cshowList :: [Storage] -> ShowS
show :: Storage -> String
$cshow :: Storage -> String
showsPrec :: Int -> Storage -> ShowS
$cshowsPrec :: Int -> Storage -> ShowS
Prelude.Show, forall x. Rep Storage x -> Storage
forall x. Storage -> Rep Storage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Storage x -> Storage
$cfrom :: forall x. Storage -> Rep Storage x
Prelude.Generic)

-- |
-- Create a value of 'Storage' 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:
--
-- 's3', 'storage_s3' - An Amazon S3 storage location.
newStorage ::
  Storage
newStorage :: Storage
newStorage = Storage' {$sel:s3:Storage' :: Maybe S3Storage
s3 = forall a. Maybe a
Prelude.Nothing}

-- | An Amazon S3 storage location.
storage_s3 :: Lens.Lens' Storage (Prelude.Maybe S3Storage)
storage_s3 :: Lens' Storage (Maybe S3Storage)
storage_s3 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Storage' {Maybe S3Storage
s3 :: Maybe S3Storage
$sel:s3:Storage' :: Storage -> Maybe S3Storage
s3} -> Maybe S3Storage
s3) (\s :: Storage
s@Storage' {} Maybe S3Storage
a -> Storage
s {$sel:s3:Storage' :: Maybe S3Storage
s3 = Maybe S3Storage
a} :: Storage)

instance Data.FromXML Storage where
  parseXML :: [Node] -> Either String Storage
parseXML [Node]
x = Maybe S3Storage -> Storage
Storage' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"S3")

instance Prelude.Hashable Storage where
  hashWithSalt :: Int -> Storage -> Int
hashWithSalt Int
_salt Storage' {Maybe S3Storage
s3 :: Maybe S3Storage
$sel:s3:Storage' :: Storage -> Maybe S3Storage
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Storage
s3

instance Prelude.NFData Storage where
  rnf :: Storage -> ()
rnf Storage' {Maybe S3Storage
s3 :: Maybe S3Storage
$sel:s3:Storage' :: Storage -> Maybe S3Storage
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Storage
s3

instance Data.ToQuery Storage where
  toQuery :: Storage -> QueryString
toQuery Storage' {Maybe S3Storage
s3 :: Maybe S3Storage
$sel:s3:Storage' :: Storage -> Maybe S3Storage
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"S3" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe S3Storage
s3]