{-# 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.ManagedBlockChain.Types.Accessor
-- 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.ManagedBlockChain.Types.Accessor where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ManagedBlockChain.Types.AccessorStatus
import Amazonka.ManagedBlockChain.Types.AccessorType
import qualified Amazonka.Prelude as Prelude

-- | The token based access feature is in preview release for Ethereum on
-- Amazon Managed Blockchain and is subject to change. We recommend that
-- you use this feature only with test scenarios, and not in production
-- environments.
--
-- The properties of the Accessor.
--
-- /See:/ 'newAccessor' smart constructor.
data Accessor = Accessor'
  { -- | The Amazon Resource Name (ARN) of the accessor. For more information
    -- about ARNs and their format, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /Amazon Web Services General Reference/.
    Accessor -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The billing token is a property of the accessor. Use this token to make
    -- Ethereum API calls to your Ethereum node. The billing token is used to
    -- track your accessor object for billing Ethereum API requests made to
    -- your Ethereum nodes.
    Accessor -> Maybe Text
billingToken :: Prelude.Maybe Prelude.Text,
    -- | The creation date and time of the accessor.
    Accessor -> Maybe ISO8601
creationDate :: Prelude.Maybe Data.ISO8601,
    -- | The unique identifier of the accessor.
    Accessor -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The current status of the accessor.
    Accessor -> Maybe AccessorStatus
status :: Prelude.Maybe AccessorStatus,
    -- | The type of the accessor.
    --
    -- Currently accessor type is restricted to @BILLING_TOKEN@.
    Accessor -> Maybe AccessorType
type' :: Prelude.Maybe AccessorType
  }
  deriving (Accessor -> Accessor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Accessor -> Accessor -> Bool
$c/= :: Accessor -> Accessor -> Bool
== :: Accessor -> Accessor -> Bool
$c== :: Accessor -> Accessor -> Bool
Prelude.Eq, ReadPrec [Accessor]
ReadPrec Accessor
Int -> ReadS Accessor
ReadS [Accessor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Accessor]
$creadListPrec :: ReadPrec [Accessor]
readPrec :: ReadPrec Accessor
$creadPrec :: ReadPrec Accessor
readList :: ReadS [Accessor]
$creadList :: ReadS [Accessor]
readsPrec :: Int -> ReadS Accessor
$creadsPrec :: Int -> ReadS Accessor
Prelude.Read, Int -> Accessor -> ShowS
[Accessor] -> ShowS
Accessor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Accessor] -> ShowS
$cshowList :: [Accessor] -> ShowS
show :: Accessor -> String
$cshow :: Accessor -> String
showsPrec :: Int -> Accessor -> ShowS
$cshowsPrec :: Int -> Accessor -> ShowS
Prelude.Show, forall x. Rep Accessor x -> Accessor
forall x. Accessor -> Rep Accessor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Accessor x -> Accessor
$cfrom :: forall x. Accessor -> Rep Accessor x
Prelude.Generic)

-- |
-- Create a value of 'Accessor' 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:
--
-- 'arn', 'accessor_arn' - The Amazon Resource Name (ARN) of the accessor. For more information
-- about ARNs and their format, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
--
-- 'billingToken', 'accessor_billingToken' - The billing token is a property of the accessor. Use this token to make
-- Ethereum API calls to your Ethereum node. The billing token is used to
-- track your accessor object for billing Ethereum API requests made to
-- your Ethereum nodes.
--
-- 'creationDate', 'accessor_creationDate' - The creation date and time of the accessor.
--
-- 'id', 'accessor_id' - The unique identifier of the accessor.
--
-- 'status', 'accessor_status' - The current status of the accessor.
--
-- 'type'', 'accessor_type' - The type of the accessor.
--
-- Currently accessor type is restricted to @BILLING_TOKEN@.
newAccessor ::
  Accessor
newAccessor :: Accessor
newAccessor =
  Accessor'
    { $sel:arn:Accessor' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:billingToken:Accessor' :: Maybe Text
billingToken = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:Accessor' :: Maybe ISO8601
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Accessor' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Accessor' :: Maybe AccessorStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Accessor' :: Maybe AccessorType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the accessor. For more information
-- about ARNs and their format, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /Amazon Web Services General Reference/.
accessor_arn :: Lens.Lens' Accessor (Prelude.Maybe Prelude.Text)
accessor_arn :: Lens' Accessor (Maybe Text)
accessor_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe Text
arn :: Maybe Text
$sel:arn:Accessor' :: Accessor -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Accessor
s@Accessor' {} Maybe Text
a -> Accessor
s {$sel:arn:Accessor' :: Maybe Text
arn = Maybe Text
a} :: Accessor)

-- | The billing token is a property of the accessor. Use this token to make
-- Ethereum API calls to your Ethereum node. The billing token is used to
-- track your accessor object for billing Ethereum API requests made to
-- your Ethereum nodes.
accessor_billingToken :: Lens.Lens' Accessor (Prelude.Maybe Prelude.Text)
accessor_billingToken :: Lens' Accessor (Maybe Text)
accessor_billingToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe Text
billingToken :: Maybe Text
$sel:billingToken:Accessor' :: Accessor -> Maybe Text
billingToken} -> Maybe Text
billingToken) (\s :: Accessor
s@Accessor' {} Maybe Text
a -> Accessor
s {$sel:billingToken:Accessor' :: Maybe Text
billingToken = Maybe Text
a} :: Accessor)

-- | The creation date and time of the accessor.
accessor_creationDate :: Lens.Lens' Accessor (Prelude.Maybe Prelude.UTCTime)
accessor_creationDate :: Lens' Accessor (Maybe UTCTime)
accessor_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe ISO8601
creationDate :: Maybe ISO8601
$sel:creationDate:Accessor' :: Accessor -> Maybe ISO8601
creationDate} -> Maybe ISO8601
creationDate) (\s :: Accessor
s@Accessor' {} Maybe ISO8601
a -> Accessor
s {$sel:creationDate:Accessor' :: Maybe ISO8601
creationDate = Maybe ISO8601
a} :: Accessor) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The unique identifier of the accessor.
accessor_id :: Lens.Lens' Accessor (Prelude.Maybe Prelude.Text)
accessor_id :: Lens' Accessor (Maybe Text)
accessor_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe Text
id :: Maybe Text
$sel:id:Accessor' :: Accessor -> Maybe Text
id} -> Maybe Text
id) (\s :: Accessor
s@Accessor' {} Maybe Text
a -> Accessor
s {$sel:id:Accessor' :: Maybe Text
id = Maybe Text
a} :: Accessor)

-- | The current status of the accessor.
accessor_status :: Lens.Lens' Accessor (Prelude.Maybe AccessorStatus)
accessor_status :: Lens' Accessor (Maybe AccessorStatus)
accessor_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe AccessorStatus
status :: Maybe AccessorStatus
$sel:status:Accessor' :: Accessor -> Maybe AccessorStatus
status} -> Maybe AccessorStatus
status) (\s :: Accessor
s@Accessor' {} Maybe AccessorStatus
a -> Accessor
s {$sel:status:Accessor' :: Maybe AccessorStatus
status = Maybe AccessorStatus
a} :: Accessor)

-- | The type of the accessor.
--
-- Currently accessor type is restricted to @BILLING_TOKEN@.
accessor_type :: Lens.Lens' Accessor (Prelude.Maybe AccessorType)
accessor_type :: Lens' Accessor (Maybe AccessorType)
accessor_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Accessor' {Maybe AccessorType
type' :: Maybe AccessorType
$sel:type':Accessor' :: Accessor -> Maybe AccessorType
type'} -> Maybe AccessorType
type') (\s :: Accessor
s@Accessor' {} Maybe AccessorType
a -> Accessor
s {$sel:type':Accessor' :: Maybe AccessorType
type' = Maybe AccessorType
a} :: Accessor)

instance Data.FromJSON Accessor where
  parseJSON :: Value -> Parser Accessor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Accessor"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Maybe Text
-> Maybe AccessorStatus
-> Maybe AccessorType
-> Accessor
Accessor'
            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
"Arn")
            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
"BillingToken")
            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
"CreationDate")
            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
"Id")
            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
"Status")
            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
"Type")
      )

instance Prelude.Hashable Accessor where
  hashWithSalt :: Int -> Accessor -> Int
hashWithSalt Int
_salt Accessor' {Maybe Text
Maybe ISO8601
Maybe AccessorStatus
Maybe AccessorType
type' :: Maybe AccessorType
status :: Maybe AccessorStatus
id :: Maybe Text
creationDate :: Maybe ISO8601
billingToken :: Maybe Text
arn :: Maybe Text
$sel:type':Accessor' :: Accessor -> Maybe AccessorType
$sel:status:Accessor' :: Accessor -> Maybe AccessorStatus
$sel:id:Accessor' :: Accessor -> Maybe Text
$sel:creationDate:Accessor' :: Accessor -> Maybe ISO8601
$sel:billingToken:Accessor' :: Accessor -> Maybe Text
$sel:arn:Accessor' :: Accessor -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
billingToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccessorStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccessorType
type'

instance Prelude.NFData Accessor where
  rnf :: Accessor -> ()
rnf Accessor' {Maybe Text
Maybe ISO8601
Maybe AccessorStatus
Maybe AccessorType
type' :: Maybe AccessorType
status :: Maybe AccessorStatus
id :: Maybe Text
creationDate :: Maybe ISO8601
billingToken :: Maybe Text
arn :: Maybe Text
$sel:type':Accessor' :: Accessor -> Maybe AccessorType
$sel:status:Accessor' :: Accessor -> Maybe AccessorStatus
$sel:id:Accessor' :: Accessor -> Maybe Text
$sel:creationDate:Accessor' :: Accessor -> Maybe ISO8601
$sel:billingToken:Accessor' :: Accessor -> Maybe Text
$sel:arn:Accessor' :: Accessor -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
billingToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessorStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessorType
type'