{-# 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.LicenseManager.Types.TokenData
-- 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.LicenseManager.Types.TokenData where

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

-- | Describes a token.
--
-- /See:/ 'newTokenData' smart constructor.
data TokenData = TokenData'
  { -- | Token status. The possible values are @AVAILABLE@ and @DELETED@.
    TokenData -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | Token ID.
    TokenData -> Maybe Text
tokenId :: Prelude.Maybe Prelude.Text,
    -- | Data specified by the caller.
    TokenData -> Maybe [Text]
tokenProperties :: Prelude.Maybe [Prelude.Text],
    -- | Amazon Resource Names (ARN) of the roles included in the token.
    TokenData -> Maybe [Text]
roleArns :: Prelude.Maybe [Prelude.Text],
    -- | Type of token generated. The supported value is @REFRESH_TOKEN@.
    TokenData -> Maybe Text
tokenType :: Prelude.Maybe Prelude.Text,
    -- | Token expiration time, in ISO8601-UTC format.
    TokenData -> Maybe Text
expirationTime :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the license.
    TokenData -> Maybe Text
licenseArn :: Prelude.Maybe Prelude.Text
  }
  deriving (TokenData -> TokenData -> Bool
(TokenData -> TokenData -> Bool)
-> (TokenData -> TokenData -> Bool) -> Eq TokenData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TokenData -> TokenData -> Bool
$c/= :: TokenData -> TokenData -> Bool
== :: TokenData -> TokenData -> Bool
$c== :: TokenData -> TokenData -> Bool
Prelude.Eq, ReadPrec [TokenData]
ReadPrec TokenData
Int -> ReadS TokenData
ReadS [TokenData]
(Int -> ReadS TokenData)
-> ReadS [TokenData]
-> ReadPrec TokenData
-> ReadPrec [TokenData]
-> Read TokenData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TokenData]
$creadListPrec :: ReadPrec [TokenData]
readPrec :: ReadPrec TokenData
$creadPrec :: ReadPrec TokenData
readList :: ReadS [TokenData]
$creadList :: ReadS [TokenData]
readsPrec :: Int -> ReadS TokenData
$creadsPrec :: Int -> ReadS TokenData
Prelude.Read, Int -> TokenData -> ShowS
[TokenData] -> ShowS
TokenData -> String
(Int -> TokenData -> ShowS)
-> (TokenData -> String)
-> ([TokenData] -> ShowS)
-> Show TokenData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TokenData] -> ShowS
$cshowList :: [TokenData] -> ShowS
show :: TokenData -> String
$cshow :: TokenData -> String
showsPrec :: Int -> TokenData -> ShowS
$cshowsPrec :: Int -> TokenData -> ShowS
Prelude.Show, (forall x. TokenData -> Rep TokenData x)
-> (forall x. Rep TokenData x -> TokenData) -> Generic TokenData
forall x. Rep TokenData x -> TokenData
forall x. TokenData -> Rep TokenData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TokenData x -> TokenData
$cfrom :: forall x. TokenData -> Rep TokenData x
Prelude.Generic)

-- |
-- Create a value of 'TokenData' 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:
--
-- 'status', 'tokenData_status' - Token status. The possible values are @AVAILABLE@ and @DELETED@.
--
-- 'tokenId', 'tokenData_tokenId' - Token ID.
--
-- 'tokenProperties', 'tokenData_tokenProperties' - Data specified by the caller.
--
-- 'roleArns', 'tokenData_roleArns' - Amazon Resource Names (ARN) of the roles included in the token.
--
-- 'tokenType', 'tokenData_tokenType' - Type of token generated. The supported value is @REFRESH_TOKEN@.
--
-- 'expirationTime', 'tokenData_expirationTime' - Token expiration time, in ISO8601-UTC format.
--
-- 'licenseArn', 'tokenData_licenseArn' - Amazon Resource Name (ARN) of the license.
newTokenData ::
  TokenData
newTokenData :: TokenData
newTokenData =
  TokenData' :: Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TokenData
TokenData'
    { $sel:status:TokenData' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenId:TokenData' :: Maybe Text
tokenId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenProperties:TokenData' :: Maybe [Text]
tokenProperties = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArns:TokenData' :: Maybe [Text]
roleArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenType:TokenData' :: Maybe Text
tokenType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationTime:TokenData' :: Maybe Text
expirationTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:licenseArn:TokenData' :: Maybe Text
licenseArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Token status. The possible values are @AVAILABLE@ and @DELETED@.
tokenData_status :: Lens.Lens' TokenData (Prelude.Maybe Prelude.Text)
tokenData_status :: (Maybe Text -> f (Maybe Text)) -> TokenData -> f TokenData
tokenData_status = (TokenData -> Maybe Text)
-> (TokenData -> Maybe Text -> TokenData)
-> Lens TokenData TokenData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe Text
status :: Maybe Text
$sel:status:TokenData' :: TokenData -> Maybe Text
status} -> Maybe Text
status) (\s :: TokenData
s@TokenData' {} Maybe Text
a -> TokenData
s {$sel:status:TokenData' :: Maybe Text
status = Maybe Text
a} :: TokenData)

-- | Token ID.
tokenData_tokenId :: Lens.Lens' TokenData (Prelude.Maybe Prelude.Text)
tokenData_tokenId :: (Maybe Text -> f (Maybe Text)) -> TokenData -> f TokenData
tokenData_tokenId = (TokenData -> Maybe Text)
-> (TokenData -> Maybe Text -> TokenData)
-> Lens TokenData TokenData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe Text
tokenId :: Maybe Text
$sel:tokenId:TokenData' :: TokenData -> Maybe Text
tokenId} -> Maybe Text
tokenId) (\s :: TokenData
s@TokenData' {} Maybe Text
a -> TokenData
s {$sel:tokenId:TokenData' :: Maybe Text
tokenId = Maybe Text
a} :: TokenData)

-- | Data specified by the caller.
tokenData_tokenProperties :: Lens.Lens' TokenData (Prelude.Maybe [Prelude.Text])
tokenData_tokenProperties :: (Maybe [Text] -> f (Maybe [Text])) -> TokenData -> f TokenData
tokenData_tokenProperties = (TokenData -> Maybe [Text])
-> (TokenData -> Maybe [Text] -> TokenData)
-> Lens TokenData TokenData (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe [Text]
tokenProperties :: Maybe [Text]
$sel:tokenProperties:TokenData' :: TokenData -> Maybe [Text]
tokenProperties} -> Maybe [Text]
tokenProperties) (\s :: TokenData
s@TokenData' {} Maybe [Text]
a -> TokenData
s {$sel:tokenProperties:TokenData' :: Maybe [Text]
tokenProperties = Maybe [Text]
a} :: TokenData) ((Maybe [Text] -> f (Maybe [Text])) -> TokenData -> f TokenData)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TokenData
-> f TokenData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Amazon Resource Names (ARN) of the roles included in the token.
tokenData_roleArns :: Lens.Lens' TokenData (Prelude.Maybe [Prelude.Text])
tokenData_roleArns :: (Maybe [Text] -> f (Maybe [Text])) -> TokenData -> f TokenData
tokenData_roleArns = (TokenData -> Maybe [Text])
-> (TokenData -> Maybe [Text] -> TokenData)
-> Lens TokenData TokenData (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe [Text]
roleArns :: Maybe [Text]
$sel:roleArns:TokenData' :: TokenData -> Maybe [Text]
roleArns} -> Maybe [Text]
roleArns) (\s :: TokenData
s@TokenData' {} Maybe [Text]
a -> TokenData
s {$sel:roleArns:TokenData' :: Maybe [Text]
roleArns = Maybe [Text]
a} :: TokenData) ((Maybe [Text] -> f (Maybe [Text])) -> TokenData -> f TokenData)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> TokenData
-> f TokenData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Type of token generated. The supported value is @REFRESH_TOKEN@.
tokenData_tokenType :: Lens.Lens' TokenData (Prelude.Maybe Prelude.Text)
tokenData_tokenType :: (Maybe Text -> f (Maybe Text)) -> TokenData -> f TokenData
tokenData_tokenType = (TokenData -> Maybe Text)
-> (TokenData -> Maybe Text -> TokenData)
-> Lens TokenData TokenData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe Text
tokenType :: Maybe Text
$sel:tokenType:TokenData' :: TokenData -> Maybe Text
tokenType} -> Maybe Text
tokenType) (\s :: TokenData
s@TokenData' {} Maybe Text
a -> TokenData
s {$sel:tokenType:TokenData' :: Maybe Text
tokenType = Maybe Text
a} :: TokenData)

-- | Token expiration time, in ISO8601-UTC format.
tokenData_expirationTime :: Lens.Lens' TokenData (Prelude.Maybe Prelude.Text)
tokenData_expirationTime :: (Maybe Text -> f (Maybe Text)) -> TokenData -> f TokenData
tokenData_expirationTime = (TokenData -> Maybe Text)
-> (TokenData -> Maybe Text -> TokenData)
-> Lens TokenData TokenData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe Text
expirationTime :: Maybe Text
$sel:expirationTime:TokenData' :: TokenData -> Maybe Text
expirationTime} -> Maybe Text
expirationTime) (\s :: TokenData
s@TokenData' {} Maybe Text
a -> TokenData
s {$sel:expirationTime:TokenData' :: Maybe Text
expirationTime = Maybe Text
a} :: TokenData)

-- | Amazon Resource Name (ARN) of the license.
tokenData_licenseArn :: Lens.Lens' TokenData (Prelude.Maybe Prelude.Text)
tokenData_licenseArn :: (Maybe Text -> f (Maybe Text)) -> TokenData -> f TokenData
tokenData_licenseArn = (TokenData -> Maybe Text)
-> (TokenData -> Maybe Text -> TokenData)
-> Lens TokenData TokenData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TokenData' {Maybe Text
licenseArn :: Maybe Text
$sel:licenseArn:TokenData' :: TokenData -> Maybe Text
licenseArn} -> Maybe Text
licenseArn) (\s :: TokenData
s@TokenData' {} Maybe Text
a -> TokenData
s {$sel:licenseArn:TokenData' :: Maybe Text
licenseArn = Maybe Text
a} :: TokenData)

instance Core.FromJSON TokenData where
  parseJSON :: Value -> Parser TokenData
parseJSON =
    String -> (Object -> Parser TokenData) -> Value -> Parser TokenData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TokenData"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> TokenData
TokenData'
            (Maybe Text
 -> Maybe Text
 -> Maybe [Text]
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> TokenData)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [Text]
      -> Maybe [Text]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> TokenData)
forall (f :: * -> *) a b. Functor 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
"Status")
            Parser
  (Maybe Text
   -> Maybe [Text]
   -> Maybe [Text]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> TokenData)
-> Parser (Maybe Text)
-> Parser
     (Maybe [Text]
      -> Maybe [Text]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> TokenData)
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
"TokenId")
            Parser
  (Maybe [Text]
   -> Maybe [Text]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> TokenData)
-> Parser (Maybe [Text])
-> Parser
     (Maybe [Text]
      -> Maybe Text -> Maybe Text -> Maybe Text -> TokenData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TokenProperties"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [Text]
   -> Maybe Text -> Maybe Text -> Maybe Text -> TokenData)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> TokenData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RoleArns" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> TokenData)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> TokenData)
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
"TokenType")
            Parser (Maybe Text -> Maybe Text -> TokenData)
-> Parser (Maybe Text) -> Parser (Maybe Text -> TokenData)
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
"ExpirationTime")
            Parser (Maybe Text -> TokenData)
-> Parser (Maybe Text) -> Parser TokenData
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
"LicenseArn")
      )

instance Prelude.Hashable TokenData

instance Prelude.NFData TokenData