{-# 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.StorageLocation
-- 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.StorageLocation 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 a storage location in Amazon S3.
--
-- /See:/ 'newStorageLocation' smart constructor.
data StorageLocation = StorageLocation'
  { -- | The name of the S3 bucket.
    StorageLocation -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The key.
    StorageLocation -> Maybe Text
key :: Prelude.Maybe Prelude.Text
  }
  deriving (StorageLocation -> StorageLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StorageLocation -> StorageLocation -> Bool
$c/= :: StorageLocation -> StorageLocation -> Bool
== :: StorageLocation -> StorageLocation -> Bool
$c== :: StorageLocation -> StorageLocation -> Bool
Prelude.Eq, ReadPrec [StorageLocation]
ReadPrec StorageLocation
Int -> ReadS StorageLocation
ReadS [StorageLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StorageLocation]
$creadListPrec :: ReadPrec [StorageLocation]
readPrec :: ReadPrec StorageLocation
$creadPrec :: ReadPrec StorageLocation
readList :: ReadS [StorageLocation]
$creadList :: ReadS [StorageLocation]
readsPrec :: Int -> ReadS StorageLocation
$creadsPrec :: Int -> ReadS StorageLocation
Prelude.Read, Int -> StorageLocation -> ShowS
[StorageLocation] -> ShowS
StorageLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StorageLocation] -> ShowS
$cshowList :: [StorageLocation] -> ShowS
show :: StorageLocation -> String
$cshow :: StorageLocation -> String
showsPrec :: Int -> StorageLocation -> ShowS
$cshowsPrec :: Int -> StorageLocation -> ShowS
Prelude.Show, forall x. Rep StorageLocation x -> StorageLocation
forall x. StorageLocation -> Rep StorageLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StorageLocation x -> StorageLocation
$cfrom :: forall x. StorageLocation -> Rep StorageLocation x
Prelude.Generic)

-- |
-- Create a value of 'StorageLocation' 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:
--
-- 'bucket', 'storageLocation_bucket' - The name of the S3 bucket.
--
-- 'key', 'storageLocation_key' - The key.
newStorageLocation ::
  StorageLocation
newStorageLocation :: StorageLocation
newStorageLocation =
  StorageLocation'
    { $sel:bucket:StorageLocation' :: Maybe Text
bucket = forall a. Maybe a
Prelude.Nothing,
      $sel:key:StorageLocation' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the S3 bucket.
storageLocation_bucket :: Lens.Lens' StorageLocation (Prelude.Maybe Prelude.Text)
storageLocation_bucket :: Lens' StorageLocation (Maybe Text)
storageLocation_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageLocation' {Maybe Text
bucket :: Maybe Text
$sel:bucket:StorageLocation' :: StorageLocation -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: StorageLocation
s@StorageLocation' {} Maybe Text
a -> StorageLocation
s {$sel:bucket:StorageLocation' :: Maybe Text
bucket = Maybe Text
a} :: StorageLocation)

-- | The key.
storageLocation_key :: Lens.Lens' StorageLocation (Prelude.Maybe Prelude.Text)
storageLocation_key :: Lens' StorageLocation (Maybe Text)
storageLocation_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageLocation' {Maybe Text
key :: Maybe Text
$sel:key:StorageLocation' :: StorageLocation -> Maybe Text
key} -> Maybe Text
key) (\s :: StorageLocation
s@StorageLocation' {} Maybe Text
a -> StorageLocation
s {$sel:key:StorageLocation' :: Maybe Text
key = Maybe Text
a} :: StorageLocation)

instance Prelude.Hashable StorageLocation where
  hashWithSalt :: Int -> StorageLocation -> Int
hashWithSalt Int
_salt StorageLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:StorageLocation' :: StorageLocation -> Maybe Text
$sel:bucket:StorageLocation' :: StorageLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key

instance Prelude.NFData StorageLocation where
  rnf :: StorageLocation -> ()
rnf StorageLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:StorageLocation' :: StorageLocation -> Maybe Text
$sel:bucket:StorageLocation' :: StorageLocation -> Maybe Text
..} =
    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
key

instance Data.ToQuery StorageLocation where
  toQuery :: StorageLocation -> QueryString
toQuery StorageLocation' {Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:key:StorageLocation' :: StorageLocation -> Maybe Text
$sel:bucket:StorageLocation' :: StorageLocation -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Bucket" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
bucket, ByteString
"Key" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
key]