{-# 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.OpenSearch.Types.PackageSource
-- 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.OpenSearch.Types.PackageSource where

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

-- | The Amazon S3 location for importing the package specified as
-- @S3BucketName@ and @S3Key@
--
-- /See:/ 'newPackageSource' smart constructor.
data PackageSource = PackageSource'
  { -- | Key (file name) of the package.
    PackageSource -> Maybe Text
s3Key :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 bucket containing the package.
    PackageSource -> Maybe Text
s3BucketName :: Prelude.Maybe Prelude.Text
  }
  deriving (PackageSource -> PackageSource -> Bool
(PackageSource -> PackageSource -> Bool)
-> (PackageSource -> PackageSource -> Bool) -> Eq PackageSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageSource -> PackageSource -> Bool
$c/= :: PackageSource -> PackageSource -> Bool
== :: PackageSource -> PackageSource -> Bool
$c== :: PackageSource -> PackageSource -> Bool
Prelude.Eq, ReadPrec [PackageSource]
ReadPrec PackageSource
Int -> ReadS PackageSource
ReadS [PackageSource]
(Int -> ReadS PackageSource)
-> ReadS [PackageSource]
-> ReadPrec PackageSource
-> ReadPrec [PackageSource]
-> Read PackageSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageSource]
$creadListPrec :: ReadPrec [PackageSource]
readPrec :: ReadPrec PackageSource
$creadPrec :: ReadPrec PackageSource
readList :: ReadS [PackageSource]
$creadList :: ReadS [PackageSource]
readsPrec :: Int -> ReadS PackageSource
$creadsPrec :: Int -> ReadS PackageSource
Prelude.Read, Int -> PackageSource -> ShowS
[PackageSource] -> ShowS
PackageSource -> String
(Int -> PackageSource -> ShowS)
-> (PackageSource -> String)
-> ([PackageSource] -> ShowS)
-> Show PackageSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageSource] -> ShowS
$cshowList :: [PackageSource] -> ShowS
show :: PackageSource -> String
$cshow :: PackageSource -> String
showsPrec :: Int -> PackageSource -> ShowS
$cshowsPrec :: Int -> PackageSource -> ShowS
Prelude.Show, (forall x. PackageSource -> Rep PackageSource x)
-> (forall x. Rep PackageSource x -> PackageSource)
-> Generic PackageSource
forall x. Rep PackageSource x -> PackageSource
forall x. PackageSource -> Rep PackageSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PackageSource x -> PackageSource
$cfrom :: forall x. PackageSource -> Rep PackageSource x
Prelude.Generic)

-- |
-- Create a value of 'PackageSource' 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:
--
-- 's3Key', 'packageSource_s3Key' - Key (file name) of the package.
--
-- 's3BucketName', 'packageSource_s3BucketName' - The name of the Amazon S3 bucket containing the package.
newPackageSource ::
  PackageSource
newPackageSource :: PackageSource
newPackageSource =
  PackageSource' :: Maybe Text -> Maybe Text -> PackageSource
PackageSource'
    { $sel:s3Key:PackageSource' :: Maybe Text
s3Key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketName:PackageSource' :: Maybe Text
s3BucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Key (file name) of the package.
packageSource_s3Key :: Lens.Lens' PackageSource (Prelude.Maybe Prelude.Text)
packageSource_s3Key :: (Maybe Text -> f (Maybe Text)) -> PackageSource -> f PackageSource
packageSource_s3Key = (PackageSource -> Maybe Text)
-> (PackageSource -> Maybe Text -> PackageSource)
-> Lens PackageSource PackageSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageSource' {Maybe Text
s3Key :: Maybe Text
$sel:s3Key:PackageSource' :: PackageSource -> Maybe Text
s3Key} -> Maybe Text
s3Key) (\s :: PackageSource
s@PackageSource' {} Maybe Text
a -> PackageSource
s {$sel:s3Key:PackageSource' :: Maybe Text
s3Key = Maybe Text
a} :: PackageSource)

-- | The name of the Amazon S3 bucket containing the package.
packageSource_s3BucketName :: Lens.Lens' PackageSource (Prelude.Maybe Prelude.Text)
packageSource_s3BucketName :: (Maybe Text -> f (Maybe Text)) -> PackageSource -> f PackageSource
packageSource_s3BucketName = (PackageSource -> Maybe Text)
-> (PackageSource -> Maybe Text -> PackageSource)
-> Lens PackageSource PackageSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageSource' {Maybe Text
s3BucketName :: Maybe Text
$sel:s3BucketName:PackageSource' :: PackageSource -> Maybe Text
s3BucketName} -> Maybe Text
s3BucketName) (\s :: PackageSource
s@PackageSource' {} Maybe Text
a -> PackageSource
s {$sel:s3BucketName:PackageSource' :: Maybe Text
s3BucketName = Maybe Text
a} :: PackageSource)

instance Prelude.Hashable PackageSource

instance Prelude.NFData PackageSource

instance Core.ToJSON PackageSource where
  toJSON :: PackageSource -> Value
toJSON PackageSource' {Maybe Text
s3BucketName :: Maybe Text
s3Key :: Maybe Text
$sel:s3BucketName:PackageSource' :: PackageSource -> Maybe Text
$sel:s3Key:PackageSource' :: PackageSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3Key" 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
s3Key,
            (Text
"S3BucketName" 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
s3BucketName
          ]
      )