{-# 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.AmplifyBackend.Types.GetBackendStorageResourceConfig
-- 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.AmplifyBackend.Types.GetBackendStorageResourceConfig where

import Amazonka.AmplifyBackend.Types.BackendStoragePermissions
import Amazonka.AmplifyBackend.Types.ServiceName
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The details for a backend storage resource.
--
-- /See:/ 'newGetBackendStorageResourceConfig' smart constructor.
data GetBackendStorageResourceConfig = GetBackendStorageResourceConfig'
  { -- | The name of the S3 bucket.
    GetBackendStorageResourceConfig -> Maybe Text
bucketName :: Prelude.Maybe Prelude.Text,
    -- | The authorization configuration for the storage S3 bucket.
    GetBackendStorageResourceConfig -> Maybe BackendStoragePermissions
permissions :: Prelude.Maybe BackendStoragePermissions,
    -- | The name of the storage service.
    GetBackendStorageResourceConfig -> ServiceName
serviceName :: ServiceName,
    -- | Returns True if the storage resource has been imported.
    GetBackendStorageResourceConfig -> Bool
imported :: Prelude.Bool
  }
  deriving (GetBackendStorageResourceConfig
-> GetBackendStorageResourceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBackendStorageResourceConfig
-> GetBackendStorageResourceConfig -> Bool
$c/= :: GetBackendStorageResourceConfig
-> GetBackendStorageResourceConfig -> Bool
== :: GetBackendStorageResourceConfig
-> GetBackendStorageResourceConfig -> Bool
$c== :: GetBackendStorageResourceConfig
-> GetBackendStorageResourceConfig -> Bool
Prelude.Eq, ReadPrec [GetBackendStorageResourceConfig]
ReadPrec GetBackendStorageResourceConfig
Int -> ReadS GetBackendStorageResourceConfig
ReadS [GetBackendStorageResourceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBackendStorageResourceConfig]
$creadListPrec :: ReadPrec [GetBackendStorageResourceConfig]
readPrec :: ReadPrec GetBackendStorageResourceConfig
$creadPrec :: ReadPrec GetBackendStorageResourceConfig
readList :: ReadS [GetBackendStorageResourceConfig]
$creadList :: ReadS [GetBackendStorageResourceConfig]
readsPrec :: Int -> ReadS GetBackendStorageResourceConfig
$creadsPrec :: Int -> ReadS GetBackendStorageResourceConfig
Prelude.Read, Int -> GetBackendStorageResourceConfig -> ShowS
[GetBackendStorageResourceConfig] -> ShowS
GetBackendStorageResourceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBackendStorageResourceConfig] -> ShowS
$cshowList :: [GetBackendStorageResourceConfig] -> ShowS
show :: GetBackendStorageResourceConfig -> String
$cshow :: GetBackendStorageResourceConfig -> String
showsPrec :: Int -> GetBackendStorageResourceConfig -> ShowS
$cshowsPrec :: Int -> GetBackendStorageResourceConfig -> ShowS
Prelude.Show, forall x.
Rep GetBackendStorageResourceConfig x
-> GetBackendStorageResourceConfig
forall x.
GetBackendStorageResourceConfig
-> Rep GetBackendStorageResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetBackendStorageResourceConfig x
-> GetBackendStorageResourceConfig
$cfrom :: forall x.
GetBackendStorageResourceConfig
-> Rep GetBackendStorageResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetBackendStorageResourceConfig' 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:
--
-- 'bucketName', 'getBackendStorageResourceConfig_bucketName' - The name of the S3 bucket.
--
-- 'permissions', 'getBackendStorageResourceConfig_permissions' - The authorization configuration for the storage S3 bucket.
--
-- 'serviceName', 'getBackendStorageResourceConfig_serviceName' - The name of the storage service.
--
-- 'imported', 'getBackendStorageResourceConfig_imported' - Returns True if the storage resource has been imported.
newGetBackendStorageResourceConfig ::
  -- | 'serviceName'
  ServiceName ->
  -- | 'imported'
  Prelude.Bool ->
  GetBackendStorageResourceConfig
newGetBackendStorageResourceConfig :: ServiceName -> Bool -> GetBackendStorageResourceConfig
newGetBackendStorageResourceConfig
  ServiceName
pServiceName_
  Bool
pImported_ =
    GetBackendStorageResourceConfig'
      { $sel:bucketName:GetBackendStorageResourceConfig' :: Maybe Text
bucketName =
          forall a. Maybe a
Prelude.Nothing,
        $sel:permissions:GetBackendStorageResourceConfig' :: Maybe BackendStoragePermissions
permissions = forall a. Maybe a
Prelude.Nothing,
        $sel:serviceName:GetBackendStorageResourceConfig' :: ServiceName
serviceName = ServiceName
pServiceName_,
        $sel:imported:GetBackendStorageResourceConfig' :: Bool
imported = Bool
pImported_
      }

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

-- | The authorization configuration for the storage S3 bucket.
getBackendStorageResourceConfig_permissions :: Lens.Lens' GetBackendStorageResourceConfig (Prelude.Maybe BackendStoragePermissions)
getBackendStorageResourceConfig_permissions :: Lens'
  GetBackendStorageResourceConfig (Maybe BackendStoragePermissions)
getBackendStorageResourceConfig_permissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBackendStorageResourceConfig' {Maybe BackendStoragePermissions
permissions :: Maybe BackendStoragePermissions
$sel:permissions:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Maybe BackendStoragePermissions
permissions} -> Maybe BackendStoragePermissions
permissions) (\s :: GetBackendStorageResourceConfig
s@GetBackendStorageResourceConfig' {} Maybe BackendStoragePermissions
a -> GetBackendStorageResourceConfig
s {$sel:permissions:GetBackendStorageResourceConfig' :: Maybe BackendStoragePermissions
permissions = Maybe BackendStoragePermissions
a} :: GetBackendStorageResourceConfig)

-- | The name of the storage service.
getBackendStorageResourceConfig_serviceName :: Lens.Lens' GetBackendStorageResourceConfig ServiceName
getBackendStorageResourceConfig_serviceName :: Lens' GetBackendStorageResourceConfig ServiceName
getBackendStorageResourceConfig_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBackendStorageResourceConfig' {ServiceName
serviceName :: ServiceName
$sel:serviceName:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> ServiceName
serviceName} -> ServiceName
serviceName) (\s :: GetBackendStorageResourceConfig
s@GetBackendStorageResourceConfig' {} ServiceName
a -> GetBackendStorageResourceConfig
s {$sel:serviceName:GetBackendStorageResourceConfig' :: ServiceName
serviceName = ServiceName
a} :: GetBackendStorageResourceConfig)

-- | Returns True if the storage resource has been imported.
getBackendStorageResourceConfig_imported :: Lens.Lens' GetBackendStorageResourceConfig Prelude.Bool
getBackendStorageResourceConfig_imported :: Lens' GetBackendStorageResourceConfig Bool
getBackendStorageResourceConfig_imported = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBackendStorageResourceConfig' {Bool
imported :: Bool
$sel:imported:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Bool
imported} -> Bool
imported) (\s :: GetBackendStorageResourceConfig
s@GetBackendStorageResourceConfig' {} Bool
a -> GetBackendStorageResourceConfig
s {$sel:imported:GetBackendStorageResourceConfig' :: Bool
imported = Bool
a} :: GetBackendStorageResourceConfig)

instance
  Data.FromJSON
    GetBackendStorageResourceConfig
  where
  parseJSON :: Value -> Parser GetBackendStorageResourceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GetBackendStorageResourceConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe BackendStoragePermissions
-> ServiceName
-> Bool
-> GetBackendStorageResourceConfig
GetBackendStorageResourceConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bucketName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"permissions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"serviceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"imported")
      )

instance
  Prelude.Hashable
    GetBackendStorageResourceConfig
  where
  hashWithSalt :: Int -> GetBackendStorageResourceConfig -> Int
hashWithSalt
    Int
_salt
    GetBackendStorageResourceConfig' {Bool
Maybe Text
Maybe BackendStoragePermissions
ServiceName
imported :: Bool
serviceName :: ServiceName
permissions :: Maybe BackendStoragePermissions
bucketName :: Maybe Text
$sel:imported:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Bool
$sel:serviceName:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> ServiceName
$sel:permissions:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Maybe BackendStoragePermissions
$sel:bucketName:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucketName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackendStoragePermissions
permissions
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ServiceName
serviceName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
imported

instance
  Prelude.NFData
    GetBackendStorageResourceConfig
  where
  rnf :: GetBackendStorageResourceConfig -> ()
rnf GetBackendStorageResourceConfig' {Bool
Maybe Text
Maybe BackendStoragePermissions
ServiceName
imported :: Bool
serviceName :: ServiceName
permissions :: Maybe BackendStoragePermissions
bucketName :: Maybe Text
$sel:imported:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Bool
$sel:serviceName:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> ServiceName
$sel:permissions:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Maybe BackendStoragePermissions
$sel:bucketName:GetBackendStorageResourceConfig' :: GetBackendStorageResourceConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BackendStoragePermissions
permissions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ServiceName
serviceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
imported