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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 are using the Amazon ECS API, CLI, or Amazon Web Services SDK,
    -- if the secret exists in the same Region as the task that you are
    -- launching then you can use either the full ARN or the name of the
    -- secret. When you are using the Amazon Web Services Management Console,
    -- you must specify the full ARN of the secret.
    RepositoryCredentials -> Text
credentialsParameter :: Prelude.Text
  }
  deriving (RepositoryCredentials -> RepositoryCredentials -> Bool
(RepositoryCredentials -> RepositoryCredentials -> Bool)
-> (RepositoryCredentials -> RepositoryCredentials -> Bool)
-> Eq RepositoryCredentials
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]
(Int -> ReadS RepositoryCredentials)
-> ReadS [RepositoryCredentials]
-> ReadPrec RepositoryCredentials
-> ReadPrec [RepositoryCredentials]
-> Read 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
(Int -> RepositoryCredentials -> ShowS)
-> (RepositoryCredentials -> String)
-> ([RepositoryCredentials] -> ShowS)
-> Show RepositoryCredentials
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. RepositoryCredentials -> Rep RepositoryCredentials x)
-> (forall x. Rep RepositoryCredentials x -> RepositoryCredentials)
-> Generic RepositoryCredentials
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 are using the Amazon ECS API, CLI, or Amazon Web Services SDK,
-- if the secret exists in the same Region as the task that you are
-- launching then you can use either the full ARN or the name of the
-- secret. When you are using 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' :: Text -> RepositoryCredentials
RepositoryCredentials'
    { $sel:credentialsParameter:RepositoryCredentials' :: Text
credentialsParameter =
        Text
pCredentialsParameter_
    }

-- | The Amazon Resource Name (ARN) of the secret containing the private
-- repository credentials.
--
-- When you are using the Amazon ECS API, CLI, or Amazon Web Services SDK,
-- if the secret exists in the same Region as the task that you are
-- launching then you can use either the full ARN or the name of the
-- secret. When you are using the Amazon Web Services Management Console,
-- you must specify the full ARN of the secret.
repositoryCredentials_credentialsParameter :: Lens.Lens' RepositoryCredentials Prelude.Text
repositoryCredentials_credentialsParameter :: (Text -> f Text)
-> RepositoryCredentials -> f RepositoryCredentials
repositoryCredentials_credentialsParameter = (RepositoryCredentials -> Text)
-> (RepositoryCredentials -> Text -> RepositoryCredentials)
-> Lens RepositoryCredentials RepositoryCredentials Text Text
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 Core.FromJSON RepositoryCredentials where
  parseJSON :: Value -> Parser RepositoryCredentials
parseJSON =
    String
-> (Object -> Parser RepositoryCredentials)
-> Value
-> Parser RepositoryCredentials
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RepositoryCredentials"
      ( \Object
x ->
          Text -> RepositoryCredentials
RepositoryCredentials'
            (Text -> RepositoryCredentials)
-> Parser Text -> Parser RepositoryCredentials
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"credentialsParameter")
      )

instance Prelude.Hashable RepositoryCredentials

instance Prelude.NFData RepositoryCredentials

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