{-# 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.Snowball.Types.S3Resource
-- 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.Snowball.Types.S3Resource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Snowball.Types.KeyRange
import Amazonka.Snowball.Types.TargetOnDeviceService

-- | Each @S3Resource@ object represents an Amazon S3 bucket that your
-- transferred data will be exported from or imported into. For export
-- jobs, this object can have an optional @KeyRange@ value. The length of
-- the range is defined at job creation, and has either an inclusive
-- @BeginMarker@, an inclusive @EndMarker@, or both. Ranges are UTF-8
-- binary sorted.
--
-- /See:/ 'newS3Resource' smart constructor.
data S3Resource = S3Resource'
  { -- | For export jobs, you can provide an optional @KeyRange@ within a
    -- specific Amazon S3 bucket. The length of the range is defined at job
    -- creation, and has either an inclusive @BeginMarker@, an inclusive
    -- @EndMarker@, or both. Ranges are UTF-8 binary sorted.
    S3Resource -> Maybe KeyRange
keyRange :: Prelude.Maybe KeyRange,
    -- | The Amazon Resource Name (ARN) of an Amazon S3 bucket.
    S3Resource -> Maybe Text
bucketArn :: Prelude.Maybe Prelude.Text,
    -- | Specifies the service or services on the Snow Family device that your
    -- transferred data will be exported from or imported into. AWS Snow Family
    -- supports Amazon S3 and NFS (Network File System).
    S3Resource -> Maybe [TargetOnDeviceService]
targetOnDeviceServices :: Prelude.Maybe [TargetOnDeviceService]
  }
  deriving (S3Resource -> S3Resource -> Bool
(S3Resource -> S3Resource -> Bool)
-> (S3Resource -> S3Resource -> Bool) -> Eq S3Resource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Resource -> S3Resource -> Bool
$c/= :: S3Resource -> S3Resource -> Bool
== :: S3Resource -> S3Resource -> Bool
$c== :: S3Resource -> S3Resource -> Bool
Prelude.Eq, ReadPrec [S3Resource]
ReadPrec S3Resource
Int -> ReadS S3Resource
ReadS [S3Resource]
(Int -> ReadS S3Resource)
-> ReadS [S3Resource]
-> ReadPrec S3Resource
-> ReadPrec [S3Resource]
-> Read S3Resource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Resource]
$creadListPrec :: ReadPrec [S3Resource]
readPrec :: ReadPrec S3Resource
$creadPrec :: ReadPrec S3Resource
readList :: ReadS [S3Resource]
$creadList :: ReadS [S3Resource]
readsPrec :: Int -> ReadS S3Resource
$creadsPrec :: Int -> ReadS S3Resource
Prelude.Read, Int -> S3Resource -> ShowS
[S3Resource] -> ShowS
S3Resource -> String
(Int -> S3Resource -> ShowS)
-> (S3Resource -> String)
-> ([S3Resource] -> ShowS)
-> Show S3Resource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Resource] -> ShowS
$cshowList :: [S3Resource] -> ShowS
show :: S3Resource -> String
$cshow :: S3Resource -> String
showsPrec :: Int -> S3Resource -> ShowS
$cshowsPrec :: Int -> S3Resource -> ShowS
Prelude.Show, (forall x. S3Resource -> Rep S3Resource x)
-> (forall x. Rep S3Resource x -> S3Resource) -> Generic S3Resource
forall x. Rep S3Resource x -> S3Resource
forall x. S3Resource -> Rep S3Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Resource x -> S3Resource
$cfrom :: forall x. S3Resource -> Rep S3Resource x
Prelude.Generic)

-- |
-- Create a value of 'S3Resource' 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:
--
-- 'keyRange', 's3Resource_keyRange' - For export jobs, you can provide an optional @KeyRange@ within a
-- specific Amazon S3 bucket. The length of the range is defined at job
-- creation, and has either an inclusive @BeginMarker@, an inclusive
-- @EndMarker@, or both. Ranges are UTF-8 binary sorted.
--
-- 'bucketArn', 's3Resource_bucketArn' - The Amazon Resource Name (ARN) of an Amazon S3 bucket.
--
-- 'targetOnDeviceServices', 's3Resource_targetOnDeviceServices' - Specifies the service or services on the Snow Family device that your
-- transferred data will be exported from or imported into. AWS Snow Family
-- supports Amazon S3 and NFS (Network File System).
newS3Resource ::
  S3Resource
newS3Resource :: S3Resource
newS3Resource =
  S3Resource' :: Maybe KeyRange
-> Maybe Text -> Maybe [TargetOnDeviceService] -> S3Resource
S3Resource'
    { $sel:keyRange:S3Resource' :: Maybe KeyRange
keyRange = Maybe KeyRange
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketArn:S3Resource' :: Maybe Text
bucketArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetOnDeviceServices:S3Resource' :: Maybe [TargetOnDeviceService]
targetOnDeviceServices = Maybe [TargetOnDeviceService]
forall a. Maybe a
Prelude.Nothing
    }

-- | For export jobs, you can provide an optional @KeyRange@ within a
-- specific Amazon S3 bucket. The length of the range is defined at job
-- creation, and has either an inclusive @BeginMarker@, an inclusive
-- @EndMarker@, or both. Ranges are UTF-8 binary sorted.
s3Resource_keyRange :: Lens.Lens' S3Resource (Prelude.Maybe KeyRange)
s3Resource_keyRange :: (Maybe KeyRange -> f (Maybe KeyRange))
-> S3Resource -> f S3Resource
s3Resource_keyRange = (S3Resource -> Maybe KeyRange)
-> (S3Resource -> Maybe KeyRange -> S3Resource)
-> Lens S3Resource S3Resource (Maybe KeyRange) (Maybe KeyRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Resource' {Maybe KeyRange
keyRange :: Maybe KeyRange
$sel:keyRange:S3Resource' :: S3Resource -> Maybe KeyRange
keyRange} -> Maybe KeyRange
keyRange) (\s :: S3Resource
s@S3Resource' {} Maybe KeyRange
a -> S3Resource
s {$sel:keyRange:S3Resource' :: Maybe KeyRange
keyRange = Maybe KeyRange
a} :: S3Resource)

-- | The Amazon Resource Name (ARN) of an Amazon S3 bucket.
s3Resource_bucketArn :: Lens.Lens' S3Resource (Prelude.Maybe Prelude.Text)
s3Resource_bucketArn :: (Maybe Text -> f (Maybe Text)) -> S3Resource -> f S3Resource
s3Resource_bucketArn = (S3Resource -> Maybe Text)
-> (S3Resource -> Maybe Text -> S3Resource)
-> Lens S3Resource S3Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Resource' {Maybe Text
bucketArn :: Maybe Text
$sel:bucketArn:S3Resource' :: S3Resource -> Maybe Text
bucketArn} -> Maybe Text
bucketArn) (\s :: S3Resource
s@S3Resource' {} Maybe Text
a -> S3Resource
s {$sel:bucketArn:S3Resource' :: Maybe Text
bucketArn = Maybe Text
a} :: S3Resource)

-- | Specifies the service or services on the Snow Family device that your
-- transferred data will be exported from or imported into. AWS Snow Family
-- supports Amazon S3 and NFS (Network File System).
s3Resource_targetOnDeviceServices :: Lens.Lens' S3Resource (Prelude.Maybe [TargetOnDeviceService])
s3Resource_targetOnDeviceServices :: (Maybe [TargetOnDeviceService]
 -> f (Maybe [TargetOnDeviceService]))
-> S3Resource -> f S3Resource
s3Resource_targetOnDeviceServices = (S3Resource -> Maybe [TargetOnDeviceService])
-> (S3Resource -> Maybe [TargetOnDeviceService] -> S3Resource)
-> Lens
     S3Resource
     S3Resource
     (Maybe [TargetOnDeviceService])
     (Maybe [TargetOnDeviceService])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Resource' {Maybe [TargetOnDeviceService]
targetOnDeviceServices :: Maybe [TargetOnDeviceService]
$sel:targetOnDeviceServices:S3Resource' :: S3Resource -> Maybe [TargetOnDeviceService]
targetOnDeviceServices} -> Maybe [TargetOnDeviceService]
targetOnDeviceServices) (\s :: S3Resource
s@S3Resource' {} Maybe [TargetOnDeviceService]
a -> S3Resource
s {$sel:targetOnDeviceServices:S3Resource' :: Maybe [TargetOnDeviceService]
targetOnDeviceServices = Maybe [TargetOnDeviceService]
a} :: S3Resource) ((Maybe [TargetOnDeviceService]
  -> f (Maybe [TargetOnDeviceService]))
 -> S3Resource -> f S3Resource)
-> ((Maybe [TargetOnDeviceService]
     -> f (Maybe [TargetOnDeviceService]))
    -> Maybe [TargetOnDeviceService]
    -> f (Maybe [TargetOnDeviceService]))
-> (Maybe [TargetOnDeviceService]
    -> f (Maybe [TargetOnDeviceService]))
-> S3Resource
-> f S3Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TargetOnDeviceService]
  [TargetOnDeviceService]
  [TargetOnDeviceService]
  [TargetOnDeviceService]
-> Iso
     (Maybe [TargetOnDeviceService])
     (Maybe [TargetOnDeviceService])
     (Maybe [TargetOnDeviceService])
     (Maybe [TargetOnDeviceService])
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 AnIso
  [TargetOnDeviceService]
  [TargetOnDeviceService]
  [TargetOnDeviceService]
  [TargetOnDeviceService]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON S3Resource where
  parseJSON :: Value -> Parser S3Resource
parseJSON =
    String
-> (Object -> Parser S3Resource) -> Value -> Parser S3Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Resource"
      ( \Object
x ->
          Maybe KeyRange
-> Maybe Text -> Maybe [TargetOnDeviceService] -> S3Resource
S3Resource'
            (Maybe KeyRange
 -> Maybe Text -> Maybe [TargetOnDeviceService] -> S3Resource)
-> Parser (Maybe KeyRange)
-> Parser
     (Maybe Text -> Maybe [TargetOnDeviceService] -> S3Resource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe KeyRange)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"KeyRange")
            Parser (Maybe Text -> Maybe [TargetOnDeviceService] -> S3Resource)
-> Parser (Maybe Text)
-> Parser (Maybe [TargetOnDeviceService] -> S3Resource)
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
"BucketArn")
            Parser (Maybe [TargetOnDeviceService] -> S3Resource)
-> Parser (Maybe [TargetOnDeviceService]) -> Parser S3Resource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [TargetOnDeviceService]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetOnDeviceServices"
                            Parser (Maybe (Maybe [TargetOnDeviceService]))
-> Maybe [TargetOnDeviceService]
-> Parser (Maybe [TargetOnDeviceService])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TargetOnDeviceService]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable S3Resource

instance Prelude.NFData S3Resource

instance Core.ToJSON S3Resource where
  toJSON :: S3Resource -> Value
toJSON S3Resource' {Maybe [TargetOnDeviceService]
Maybe Text
Maybe KeyRange
targetOnDeviceServices :: Maybe [TargetOnDeviceService]
bucketArn :: Maybe Text
keyRange :: Maybe KeyRange
$sel:targetOnDeviceServices:S3Resource' :: S3Resource -> Maybe [TargetOnDeviceService]
$sel:bucketArn:S3Resource' :: S3Resource -> Maybe Text
$sel:keyRange:S3Resource' :: S3Resource -> Maybe KeyRange
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KeyRange" Text -> KeyRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (KeyRange -> Pair) -> Maybe KeyRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KeyRange
keyRange,
            (Text
"BucketArn" 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
bucketArn,
            (Text
"TargetOnDeviceServices" Text -> [TargetOnDeviceService] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([TargetOnDeviceService] -> Pair)
-> Maybe [TargetOnDeviceService] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TargetOnDeviceService]
targetOnDeviceServices
          ]
      )