{-# 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.ECS.Types.RepositoryCredentials
-- 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.ECS.Types.RepositoryCredentials where

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 repository credentials for private registry authentication.
--
-- /See:/ 'newRepositoryCredentials' smart constructor.
data RepositoryCredentials = RepositoryCredentials'
  { -- | The Amazon Resource Name (ARN) of the secret containing the private
    -- repository credentials.
    --
    -- When you use the Amazon ECS API, CLI, or Amazon Web Services SDK, if the
    -- secret exists in the same Region as the task that you\'re launching then
    -- you can use either the full ARN or the name of the secret. When you use
    -- the Amazon Web Services Management Console, you must specify the full
    -- ARN of the secret.
    RepositoryCredentials -> Text
credentialsParameter :: Prelude.Text
  }
  deriving (RepositoryCredentials -> RepositoryCredentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepositoryCredentials -> RepositoryCredentials -> Bool
$c/= :: RepositoryCredentials -> RepositoryCredentials -> Bool
== :: RepositoryCredentials -> RepositoryCredentials -> Bool
$c== :: RepositoryCredentials -> RepositoryCredentials -> Bool
Prelude.Eq, ReadPrec [RepositoryCredentials]
ReadPrec RepositoryCredentials
Int -> ReadS RepositoryCredentials
ReadS [RepositoryCredentials]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepositoryCredentials]
$creadListPrec :: ReadPrec [RepositoryCredentials]
readPrec :: ReadPrec RepositoryCredentials
$creadPrec :: ReadPrec RepositoryCredentials
readList :: ReadS [RepositoryCredentials]
$creadList :: ReadS [RepositoryCredentials]
readsPrec :: Int -> ReadS RepositoryCredentials
$creadsPrec :: Int -> ReadS RepositoryCredentials
Prelude.Read, Int -> RepositoryCredentials -> ShowS
[RepositoryCredentials] -> ShowS
RepositoryCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepositoryCredentials] -> ShowS
$cshowList :: [RepositoryCredentials] -> ShowS
show :: RepositoryCredentials -> String
$cshow :: RepositoryCredentials -> String
showsPrec :: Int -> RepositoryCredentials -> ShowS
$cshowsPrec :: Int -> RepositoryCredentials -> ShowS
Prelude.Show, forall x. Rep RepositoryCredentials x -> RepositoryCredentials
forall x. RepositoryCredentials -> Rep RepositoryCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RepositoryCredentials x -> RepositoryCredentials
$cfrom :: forall x. RepositoryCredentials -> Rep RepositoryCredentials x
Prelude.Generic)

-- |
-- Create a value of 'RepositoryCredentials' 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:
--
-- 'credentialsParameter', 'repositoryCredentials_credentialsParameter' - The Amazon Resource Name (ARN) of the secret containing the private
-- repository credentials.
--
-- When you use the Amazon ECS API, CLI, or Amazon Web Services SDK, if the
-- secret exists in the same Region as the task that you\'re launching then
-- you can use either the full ARN or the name of the secret. When you use
-- the Amazon Web Services Management Console, you must specify the full
-- ARN of the secret.
newRepositoryCredentials ::
  -- | 'credentialsParameter'
  Prelude.Text ->
  RepositoryCredentials
newRepositoryCredentials :: Text -> RepositoryCredentials
newRepositoryCredentials Text
pCredentialsParameter_ =
  RepositoryCredentials'
    { $sel:credentialsParameter:RepositoryCredentials' :: Text
credentialsParameter =
        Text
pCredentialsParameter_
    }

-- | The Amazon Resource Name (ARN) of the secret containing the private
-- repository credentials.
--
-- When you use the Amazon ECS API, CLI, or Amazon Web Services SDK, if the
-- secret exists in the same Region as the task that you\'re launching then
-- you can use either the full ARN or the name of the secret. When you use
-- the Amazon Web Services Management Console, you must specify the full
-- ARN of the secret.
repositoryCredentials_credentialsParameter :: Lens.Lens' RepositoryCredentials Prelude.Text
repositoryCredentials_credentialsParameter :: Lens' RepositoryCredentials Text
repositoryCredentials_credentialsParameter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositoryCredentials' {Text
credentialsParameter :: Text
$sel:credentialsParameter:RepositoryCredentials' :: RepositoryCredentials -> Text
credentialsParameter} -> Text
credentialsParameter) (\s :: RepositoryCredentials
s@RepositoryCredentials' {} Text
a -> RepositoryCredentials
s {$sel:credentialsParameter:RepositoryCredentials' :: Text
credentialsParameter = Text
a} :: RepositoryCredentials)

instance Data.FromJSON RepositoryCredentials where
  parseJSON :: Value -> Parser RepositoryCredentials
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RepositoryCredentials"
      ( \Object
x ->
          Text -> RepositoryCredentials
RepositoryCredentials'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"credentialsParameter")
      )

instance Prelude.Hashable RepositoryCredentials where
  hashWithSalt :: Int -> RepositoryCredentials -> Int
hashWithSalt Int
_salt RepositoryCredentials' {Text
credentialsParameter :: Text
$sel:credentialsParameter:RepositoryCredentials' :: RepositoryCredentials -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
credentialsParameter

instance Prelude.NFData RepositoryCredentials where
  rnf :: RepositoryCredentials -> ()
rnf RepositoryCredentials' {Text
credentialsParameter :: Text
$sel:credentialsParameter:RepositoryCredentials' :: RepositoryCredentials -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
credentialsParameter

instance Data.ToJSON RepositoryCredentials where
  toJSON :: RepositoryCredentials -> Value
toJSON RepositoryCredentials' {Text
credentialsParameter :: Text
$sel:credentialsParameter:RepositoryCredentials' :: RepositoryCredentials -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"credentialsParameter"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
credentialsParameter
              )
          ]
      )