{-# 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.ECR.Types.AuthorizationData
-- 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.ECR.Types.AuthorizationData where

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

-- | An object representing authorization data for an Amazon ECR registry.
--
-- /See:/ 'newAuthorizationData' smart constructor.
data AuthorizationData = AuthorizationData'
  { -- | The Unix time in seconds and milliseconds when the authorization token
    -- expires. Authorization tokens are valid for 12 hours.
    AuthorizationData -> Maybe POSIX
expiresAt :: Prelude.Maybe Core.POSIX,
    -- | The registry URL to use for this authorization token in a @docker login@
    -- command. The Amazon ECR registry URL format is
    -- @https:\/\/aws_account_id.dkr.ecr.region.amazonaws.com@. For example,
    -- @https:\/\/012345678910.dkr.ecr.us-east-1.amazonaws.com@..
    AuthorizationData -> Maybe Text
proxyEndpoint :: Prelude.Maybe Prelude.Text,
    -- | A base64-encoded string that contains authorization data for the
    -- specified Amazon ECR registry. When the string is decoded, it is
    -- presented in the format @user:password@ for private registry
    -- authentication using @docker login@.
    AuthorizationData -> Maybe Text
authorizationToken :: Prelude.Maybe Prelude.Text
  }
  deriving (AuthorizationData -> AuthorizationData -> Bool
(AuthorizationData -> AuthorizationData -> Bool)
-> (AuthorizationData -> AuthorizationData -> Bool)
-> Eq AuthorizationData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthorizationData -> AuthorizationData -> Bool
$c/= :: AuthorizationData -> AuthorizationData -> Bool
== :: AuthorizationData -> AuthorizationData -> Bool
$c== :: AuthorizationData -> AuthorizationData -> Bool
Prelude.Eq, ReadPrec [AuthorizationData]
ReadPrec AuthorizationData
Int -> ReadS AuthorizationData
ReadS [AuthorizationData]
(Int -> ReadS AuthorizationData)
-> ReadS [AuthorizationData]
-> ReadPrec AuthorizationData
-> ReadPrec [AuthorizationData]
-> Read AuthorizationData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthorizationData]
$creadListPrec :: ReadPrec [AuthorizationData]
readPrec :: ReadPrec AuthorizationData
$creadPrec :: ReadPrec AuthorizationData
readList :: ReadS [AuthorizationData]
$creadList :: ReadS [AuthorizationData]
readsPrec :: Int -> ReadS AuthorizationData
$creadsPrec :: Int -> ReadS AuthorizationData
Prelude.Read, Int -> AuthorizationData -> ShowS
[AuthorizationData] -> ShowS
AuthorizationData -> String
(Int -> AuthorizationData -> ShowS)
-> (AuthorizationData -> String)
-> ([AuthorizationData] -> ShowS)
-> Show AuthorizationData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthorizationData] -> ShowS
$cshowList :: [AuthorizationData] -> ShowS
show :: AuthorizationData -> String
$cshow :: AuthorizationData -> String
showsPrec :: Int -> AuthorizationData -> ShowS
$cshowsPrec :: Int -> AuthorizationData -> ShowS
Prelude.Show, (forall x. AuthorizationData -> Rep AuthorizationData x)
-> (forall x. Rep AuthorizationData x -> AuthorizationData)
-> Generic AuthorizationData
forall x. Rep AuthorizationData x -> AuthorizationData
forall x. AuthorizationData -> Rep AuthorizationData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthorizationData x -> AuthorizationData
$cfrom :: forall x. AuthorizationData -> Rep AuthorizationData x
Prelude.Generic)

-- |
-- Create a value of 'AuthorizationData' 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:
--
-- 'expiresAt', 'authorizationData_expiresAt' - The Unix time in seconds and milliseconds when the authorization token
-- expires. Authorization tokens are valid for 12 hours.
--
-- 'proxyEndpoint', 'authorizationData_proxyEndpoint' - The registry URL to use for this authorization token in a @docker login@
-- command. The Amazon ECR registry URL format is
-- @https:\/\/aws_account_id.dkr.ecr.region.amazonaws.com@. For example,
-- @https:\/\/012345678910.dkr.ecr.us-east-1.amazonaws.com@..
--
-- 'authorizationToken', 'authorizationData_authorizationToken' - A base64-encoded string that contains authorization data for the
-- specified Amazon ECR registry. When the string is decoded, it is
-- presented in the format @user:password@ for private registry
-- authentication using @docker login@.
newAuthorizationData ::
  AuthorizationData
newAuthorizationData :: AuthorizationData
newAuthorizationData =
  AuthorizationData' :: Maybe POSIX -> Maybe Text -> Maybe Text -> AuthorizationData
AuthorizationData'
    { $sel:expiresAt:AuthorizationData' :: Maybe POSIX
expiresAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:proxyEndpoint:AuthorizationData' :: Maybe Text
proxyEndpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authorizationToken:AuthorizationData' :: Maybe Text
authorizationToken = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Unix time in seconds and milliseconds when the authorization token
-- expires. Authorization tokens are valid for 12 hours.
authorizationData_expiresAt :: Lens.Lens' AuthorizationData (Prelude.Maybe Prelude.UTCTime)
authorizationData_expiresAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AuthorizationData -> f AuthorizationData
authorizationData_expiresAt = (AuthorizationData -> Maybe POSIX)
-> (AuthorizationData -> Maybe POSIX -> AuthorizationData)
-> Lens
     AuthorizationData AuthorizationData (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationData' {Maybe POSIX
expiresAt :: Maybe POSIX
$sel:expiresAt:AuthorizationData' :: AuthorizationData -> Maybe POSIX
expiresAt} -> Maybe POSIX
expiresAt) (\s :: AuthorizationData
s@AuthorizationData' {} Maybe POSIX
a -> AuthorizationData
s {$sel:expiresAt:AuthorizationData' :: Maybe POSIX
expiresAt = Maybe POSIX
a} :: AuthorizationData) ((Maybe POSIX -> f (Maybe POSIX))
 -> AuthorizationData -> f AuthorizationData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AuthorizationData
-> f AuthorizationData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The registry URL to use for this authorization token in a @docker login@
-- command. The Amazon ECR registry URL format is
-- @https:\/\/aws_account_id.dkr.ecr.region.amazonaws.com@. For example,
-- @https:\/\/012345678910.dkr.ecr.us-east-1.amazonaws.com@..
authorizationData_proxyEndpoint :: Lens.Lens' AuthorizationData (Prelude.Maybe Prelude.Text)
authorizationData_proxyEndpoint :: (Maybe Text -> f (Maybe Text))
-> AuthorizationData -> f AuthorizationData
authorizationData_proxyEndpoint = (AuthorizationData -> Maybe Text)
-> (AuthorizationData -> Maybe Text -> AuthorizationData)
-> Lens
     AuthorizationData AuthorizationData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationData' {Maybe Text
proxyEndpoint :: Maybe Text
$sel:proxyEndpoint:AuthorizationData' :: AuthorizationData -> Maybe Text
proxyEndpoint} -> Maybe Text
proxyEndpoint) (\s :: AuthorizationData
s@AuthorizationData' {} Maybe Text
a -> AuthorizationData
s {$sel:proxyEndpoint:AuthorizationData' :: Maybe Text
proxyEndpoint = Maybe Text
a} :: AuthorizationData)

-- | A base64-encoded string that contains authorization data for the
-- specified Amazon ECR registry. When the string is decoded, it is
-- presented in the format @user:password@ for private registry
-- authentication using @docker login@.
authorizationData_authorizationToken :: Lens.Lens' AuthorizationData (Prelude.Maybe Prelude.Text)
authorizationData_authorizationToken :: (Maybe Text -> f (Maybe Text))
-> AuthorizationData -> f AuthorizationData
authorizationData_authorizationToken = (AuthorizationData -> Maybe Text)
-> (AuthorizationData -> Maybe Text -> AuthorizationData)
-> Lens
     AuthorizationData AuthorizationData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationData' {Maybe Text
authorizationToken :: Maybe Text
$sel:authorizationToken:AuthorizationData' :: AuthorizationData -> Maybe Text
authorizationToken} -> Maybe Text
authorizationToken) (\s :: AuthorizationData
s@AuthorizationData' {} Maybe Text
a -> AuthorizationData
s {$sel:authorizationToken:AuthorizationData' :: Maybe Text
authorizationToken = Maybe Text
a} :: AuthorizationData)

instance Core.FromJSON AuthorizationData where
  parseJSON :: Value -> Parser AuthorizationData
parseJSON =
    String
-> (Object -> Parser AuthorizationData)
-> Value
-> Parser AuthorizationData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AuthorizationData"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe Text -> AuthorizationData
AuthorizationData'
            (Maybe POSIX -> Maybe Text -> Maybe Text -> AuthorizationData)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> AuthorizationData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"expiresAt")
            Parser (Maybe Text -> Maybe Text -> AuthorizationData)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AuthorizationData)
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
"proxyEndpoint")
            Parser (Maybe Text -> AuthorizationData)
-> Parser (Maybe Text) -> Parser AuthorizationData
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
"authorizationToken")
      )

instance Prelude.Hashable AuthorizationData

instance Prelude.NFData AuthorizationData