{-# 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.RobOMaker.Types.OutputLocation
-- 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.RobOMaker.Types.OutputLocation where

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

-- | The output location.
--
-- /See:/ 'newOutputLocation' smart constructor.
data OutputLocation = OutputLocation'
  { -- | The S3 folder in the @s3Bucket@ where output files will be placed.
    OutputLocation -> Maybe Text
s3Prefix :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket for output.
    OutputLocation -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text
  }
  deriving (OutputLocation -> OutputLocation -> Bool
(OutputLocation -> OutputLocation -> Bool)
-> (OutputLocation -> OutputLocation -> Bool) -> Eq OutputLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputLocation -> OutputLocation -> Bool
$c/= :: OutputLocation -> OutputLocation -> Bool
== :: OutputLocation -> OutputLocation -> Bool
$c== :: OutputLocation -> OutputLocation -> Bool
Prelude.Eq, ReadPrec [OutputLocation]
ReadPrec OutputLocation
Int -> ReadS OutputLocation
ReadS [OutputLocation]
(Int -> ReadS OutputLocation)
-> ReadS [OutputLocation]
-> ReadPrec OutputLocation
-> ReadPrec [OutputLocation]
-> Read OutputLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputLocation]
$creadListPrec :: ReadPrec [OutputLocation]
readPrec :: ReadPrec OutputLocation
$creadPrec :: ReadPrec OutputLocation
readList :: ReadS [OutputLocation]
$creadList :: ReadS [OutputLocation]
readsPrec :: Int -> ReadS OutputLocation
$creadsPrec :: Int -> ReadS OutputLocation
Prelude.Read, Int -> OutputLocation -> ShowS
[OutputLocation] -> ShowS
OutputLocation -> String
(Int -> OutputLocation -> ShowS)
-> (OutputLocation -> String)
-> ([OutputLocation] -> ShowS)
-> Show OutputLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputLocation] -> ShowS
$cshowList :: [OutputLocation] -> ShowS
show :: OutputLocation -> String
$cshow :: OutputLocation -> String
showsPrec :: Int -> OutputLocation -> ShowS
$cshowsPrec :: Int -> OutputLocation -> ShowS
Prelude.Show, (forall x. OutputLocation -> Rep OutputLocation x)
-> (forall x. Rep OutputLocation x -> OutputLocation)
-> Generic OutputLocation
forall x. Rep OutputLocation x -> OutputLocation
forall x. OutputLocation -> Rep OutputLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputLocation x -> OutputLocation
$cfrom :: forall x. OutputLocation -> Rep OutputLocation x
Prelude.Generic)

-- |
-- Create a value of 'OutputLocation' 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:
--
-- 's3Prefix', 'outputLocation_s3Prefix' - The S3 folder in the @s3Bucket@ where output files will be placed.
--
-- 's3Bucket', 'outputLocation_s3Bucket' - The S3 bucket for output.
newOutputLocation ::
  OutputLocation
newOutputLocation :: OutputLocation
newOutputLocation =
  OutputLocation' :: Maybe Text -> Maybe Text -> OutputLocation
OutputLocation'
    { $sel:s3Prefix:OutputLocation' :: Maybe Text
s3Prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:OutputLocation' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The S3 folder in the @s3Bucket@ where output files will be placed.
outputLocation_s3Prefix :: Lens.Lens' OutputLocation (Prelude.Maybe Prelude.Text)
outputLocation_s3Prefix :: (Maybe Text -> f (Maybe Text))
-> OutputLocation -> f OutputLocation
outputLocation_s3Prefix = (OutputLocation -> Maybe Text)
-> (OutputLocation -> Maybe Text -> OutputLocation)
-> Lens OutputLocation OutputLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputLocation' {Maybe Text
s3Prefix :: Maybe Text
$sel:s3Prefix:OutputLocation' :: OutputLocation -> Maybe Text
s3Prefix} -> Maybe Text
s3Prefix) (\s :: OutputLocation
s@OutputLocation' {} Maybe Text
a -> OutputLocation
s {$sel:s3Prefix:OutputLocation' :: Maybe Text
s3Prefix = Maybe Text
a} :: OutputLocation)

-- | The S3 bucket for output.
outputLocation_s3Bucket :: Lens.Lens' OutputLocation (Prelude.Maybe Prelude.Text)
outputLocation_s3Bucket :: (Maybe Text -> f (Maybe Text))
-> OutputLocation -> f OutputLocation
outputLocation_s3Bucket = (OutputLocation -> Maybe Text)
-> (OutputLocation -> Maybe Text -> OutputLocation)
-> Lens OutputLocation OutputLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputLocation' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:OutputLocation' :: OutputLocation -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: OutputLocation
s@OutputLocation' {} Maybe Text
a -> OutputLocation
s {$sel:s3Bucket:OutputLocation' :: Maybe Text
s3Bucket = Maybe Text
a} :: OutputLocation)

instance Core.FromJSON OutputLocation where
  parseJSON :: Value -> Parser OutputLocation
parseJSON =
    String
-> (Object -> Parser OutputLocation)
-> Value
-> Parser OutputLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputLocation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> OutputLocation
OutputLocation'
            (Maybe Text -> Maybe Text -> OutputLocation)
-> Parser (Maybe Text) -> Parser (Maybe Text -> OutputLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Prefix")
            Parser (Maybe Text -> OutputLocation)
-> Parser (Maybe Text) -> Parser OutputLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Bucket")
      )

instance Prelude.Hashable OutputLocation

instance Prelude.NFData OutputLocation

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