{-# 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.S3Storage
-- 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.S3Storage 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 qualified Amazonka.Prelude as Prelude

-- | Describes the storage parameters for Amazon S3 and Amazon S3 buckets for
-- an instance store-backed AMI.
--
-- /See:/ 'newS3Storage' smart constructor.
data S3Storage = S3Storage'
  { -- | The access key ID of the owner of the bucket. Before you specify a value
    -- for your access key ID, review and follow the guidance in
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html Best practices for managing Amazon Web Services access keys>.
    S3Storage -> Maybe Text
aWSAccessKeyId :: Prelude.Maybe Prelude.Text,
    -- | The bucket in which to store the AMI. You can specify a bucket that you
    -- already own or a new bucket that Amazon EC2 creates on your behalf. If
    -- you specify a bucket that belongs to someone else, Amazon EC2 returns an
    -- error.
    S3Storage -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The beginning of the file name of the AMI.
    S3Storage -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | An Amazon S3 upload policy that gives Amazon EC2 permission to upload
    -- items into Amazon S3 on your behalf.
    S3Storage -> Maybe Base64
uploadPolicy :: Prelude.Maybe Data.Base64,
    -- | The signature of the JSON document.
    S3Storage -> Maybe Text
uploadPolicySignature :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Storage -> S3Storage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Storage -> S3Storage -> Bool
$c/= :: S3Storage -> S3Storage -> Bool
== :: S3Storage -> S3Storage -> Bool
$c== :: S3Storage -> S3Storage -> Bool
Prelude.Eq, ReadPrec [S3Storage]
ReadPrec S3Storage
Int -> ReadS S3Storage
ReadS [S3Storage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Storage]
$creadListPrec :: ReadPrec [S3Storage]
readPrec :: ReadPrec S3Storage
$creadPrec :: ReadPrec S3Storage
readList :: ReadS [S3Storage]
$creadList :: ReadS [S3Storage]
readsPrec :: Int -> ReadS S3Storage
$creadsPrec :: Int -> ReadS S3Storage
Prelude.Read, Int -> S3Storage -> ShowS
[S3Storage] -> ShowS
S3Storage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Storage] -> ShowS
$cshowList :: [S3Storage] -> ShowS
show :: S3Storage -> String
$cshow :: S3Storage -> String
showsPrec :: Int -> S3Storage -> ShowS
$cshowsPrec :: Int -> S3Storage -> ShowS
Prelude.Show, forall x. Rep S3Storage x -> S3Storage
forall x. S3Storage -> Rep S3Storage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Storage x -> S3Storage
$cfrom :: forall x. S3Storage -> Rep S3Storage x
Prelude.Generic)

-- |
-- Create a value of 'S3Storage' 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:
--
-- 'aWSAccessKeyId', 's3Storage_aWSAccessKeyId' - The access key ID of the owner of the bucket. Before you specify a value
-- for your access key ID, review and follow the guidance in
-- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html Best practices for managing Amazon Web Services access keys>.
--
-- 'bucket', 's3Storage_bucket' - The bucket in which to store the AMI. You can specify a bucket that you
-- already own or a new bucket that Amazon EC2 creates on your behalf. If
-- you specify a bucket that belongs to someone else, Amazon EC2 returns an
-- error.
--
-- 'prefix', 's3Storage_prefix' - The beginning of the file name of the AMI.
--
-- 'uploadPolicy', 's3Storage_uploadPolicy' - An Amazon S3 upload policy that gives Amazon EC2 permission to upload
-- items into Amazon S3 on your behalf.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'uploadPolicySignature', 's3Storage_uploadPolicySignature' - The signature of the JSON document.
newS3Storage ::
  S3Storage
newS3Storage :: S3Storage
newS3Storage =
  S3Storage'
    { $sel:aWSAccessKeyId:S3Storage' :: Maybe Text
aWSAccessKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:S3Storage' :: Maybe Text
bucket = forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:S3Storage' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:uploadPolicy:S3Storage' :: Maybe Base64
uploadPolicy = forall a. Maybe a
Prelude.Nothing,
      $sel:uploadPolicySignature:S3Storage' :: Maybe Text
uploadPolicySignature = forall a. Maybe a
Prelude.Nothing
    }

-- | The access key ID of the owner of the bucket. Before you specify a value
-- for your access key ID, review and follow the guidance in
-- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html Best practices for managing Amazon Web Services access keys>.
s3Storage_aWSAccessKeyId :: Lens.Lens' S3Storage (Prelude.Maybe Prelude.Text)
s3Storage_aWSAccessKeyId :: Lens' S3Storage (Maybe Text)
s3Storage_aWSAccessKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Storage' {Maybe Text
aWSAccessKeyId :: Maybe Text
$sel:aWSAccessKeyId:S3Storage' :: S3Storage -> Maybe Text
aWSAccessKeyId} -> Maybe Text
aWSAccessKeyId) (\s :: S3Storage
s@S3Storage' {} Maybe Text
a -> S3Storage
s {$sel:aWSAccessKeyId:S3Storage' :: Maybe Text
aWSAccessKeyId = Maybe Text
a} :: S3Storage)

-- | The bucket in which to store the AMI. You can specify a bucket that you
-- already own or a new bucket that Amazon EC2 creates on your behalf. If
-- you specify a bucket that belongs to someone else, Amazon EC2 returns an
-- error.
s3Storage_bucket :: Lens.Lens' S3Storage (Prelude.Maybe Prelude.Text)
s3Storage_bucket :: Lens' S3Storage (Maybe Text)
s3Storage_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Storage' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3Storage' :: S3Storage -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3Storage
s@S3Storage' {} Maybe Text
a -> S3Storage
s {$sel:bucket:S3Storage' :: Maybe Text
bucket = Maybe Text
a} :: S3Storage)

-- | The beginning of the file name of the AMI.
s3Storage_prefix :: Lens.Lens' S3Storage (Prelude.Maybe Prelude.Text)
s3Storage_prefix :: Lens' S3Storage (Maybe Text)
s3Storage_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Storage' {Maybe Text
prefix :: Maybe Text
$sel:prefix:S3Storage' :: S3Storage -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: S3Storage
s@S3Storage' {} Maybe Text
a -> S3Storage
s {$sel:prefix:S3Storage' :: Maybe Text
prefix = Maybe Text
a} :: S3Storage)

-- | An Amazon S3 upload policy that gives Amazon EC2 permission to upload
-- items into Amazon S3 on your behalf.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
s3Storage_uploadPolicy :: Lens.Lens' S3Storage (Prelude.Maybe Prelude.ByteString)
s3Storage_uploadPolicy :: Lens' S3Storage (Maybe ByteString)
s3Storage_uploadPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Storage' {Maybe Base64
uploadPolicy :: Maybe Base64
$sel:uploadPolicy:S3Storage' :: S3Storage -> Maybe Base64
uploadPolicy} -> Maybe Base64
uploadPolicy) (\s :: S3Storage
s@S3Storage' {} Maybe Base64
a -> S3Storage
s {$sel:uploadPolicy:S3Storage' :: Maybe Base64
uploadPolicy = Maybe Base64
a} :: S3Storage) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 Iso' Base64 ByteString
Data._Base64

-- | The signature of the JSON document.
s3Storage_uploadPolicySignature :: Lens.Lens' S3Storage (Prelude.Maybe Prelude.Text)
s3Storage_uploadPolicySignature :: Lens' S3Storage (Maybe Text)
s3Storage_uploadPolicySignature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Storage' {Maybe Text
uploadPolicySignature :: Maybe Text
$sel:uploadPolicySignature:S3Storage' :: S3Storage -> Maybe Text
uploadPolicySignature} -> Maybe Text
uploadPolicySignature) (\s :: S3Storage
s@S3Storage' {} Maybe Text
a -> S3Storage
s {$sel:uploadPolicySignature:S3Storage' :: Maybe Text
uploadPolicySignature = Maybe Text
a} :: S3Storage)

instance Data.FromXML S3Storage where
  parseXML :: [Node] -> Either String S3Storage
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Base64
-> Maybe Text
-> S3Storage
S3Storage'
      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
"AWSAccessKeyId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"bucket")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"prefix")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"uploadPolicy")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"uploadPolicySignature")

instance Prelude.Hashable S3Storage where
  hashWithSalt :: Int -> S3Storage -> Int
hashWithSalt Int
_salt S3Storage' {Maybe Text
Maybe Base64
uploadPolicySignature :: Maybe Text
uploadPolicy :: Maybe Base64
prefix :: Maybe Text
bucket :: Maybe Text
aWSAccessKeyId :: Maybe Text
$sel:uploadPolicySignature:S3Storage' :: S3Storage -> Maybe Text
$sel:uploadPolicy:S3Storage' :: S3Storage -> Maybe Base64
$sel:prefix:S3Storage' :: S3Storage -> Maybe Text
$sel:bucket:S3Storage' :: S3Storage -> Maybe Text
$sel:aWSAccessKeyId:S3Storage' :: S3Storage -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
aWSAccessKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
uploadPolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
uploadPolicySignature

instance Prelude.NFData S3Storage where
  rnf :: S3Storage -> ()
rnf S3Storage' {Maybe Text
Maybe Base64
uploadPolicySignature :: Maybe Text
uploadPolicy :: Maybe Base64
prefix :: Maybe Text
bucket :: Maybe Text
aWSAccessKeyId :: Maybe Text
$sel:uploadPolicySignature:S3Storage' :: S3Storage -> Maybe Text
$sel:uploadPolicy:S3Storage' :: S3Storage -> Maybe Base64
$sel:prefix:S3Storage' :: S3Storage -> Maybe Text
$sel:bucket:S3Storage' :: S3Storage -> Maybe Text
$sel:aWSAccessKeyId:S3Storage' :: S3Storage -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
aWSAccessKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
uploadPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
uploadPolicySignature

instance Data.ToQuery S3Storage where
  toQuery :: S3Storage -> QueryString
toQuery S3Storage' {Maybe Text
Maybe Base64
uploadPolicySignature :: Maybe Text
uploadPolicy :: Maybe Base64
prefix :: Maybe Text
bucket :: Maybe Text
aWSAccessKeyId :: Maybe Text
$sel:uploadPolicySignature:S3Storage' :: S3Storage -> Maybe Text
$sel:uploadPolicy:S3Storage' :: S3Storage -> Maybe Base64
$sel:prefix:S3Storage' :: S3Storage -> Maybe Text
$sel:bucket:S3Storage' :: S3Storage -> Maybe Text
$sel:aWSAccessKeyId:S3Storage' :: S3Storage -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"AWSAccessKeyId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
aWSAccessKeyId,
        ByteString
"Bucket" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
bucket,
        ByteString
"Prefix" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
prefix,
        ByteString
"UploadPolicy" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Base64
uploadPolicy,
        ByteString
"UploadPolicySignature"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
uploadPolicySignature
      ]