{-# 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.EC2.Types.IdFormat
-- 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.EC2.Types.IdFormat where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | Describes the ID format for a resource.
--
-- /See:/ 'newIdFormat' smart constructor.
data IdFormat = IdFormat'
  { -- | The date in UTC at which you are permanently switched over to using
    -- longer IDs. If a deadline is not yet available for this resource type,
    -- this field is not returned.
    IdFormat -> Maybe ISO8601
deadline :: Prelude.Maybe Data.ISO8601,
    -- | The type of resource.
    IdFormat -> Maybe Text
resource :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether longer IDs (17-character IDs) are enabled for the
    -- resource.
    IdFormat -> Maybe Bool
useLongIds :: Prelude.Maybe Prelude.Bool
  }
  deriving (IdFormat -> IdFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdFormat -> IdFormat -> Bool
$c/= :: IdFormat -> IdFormat -> Bool
== :: IdFormat -> IdFormat -> Bool
$c== :: IdFormat -> IdFormat -> Bool
Prelude.Eq, ReadPrec [IdFormat]
ReadPrec IdFormat
Int -> ReadS IdFormat
ReadS [IdFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdFormat]
$creadListPrec :: ReadPrec [IdFormat]
readPrec :: ReadPrec IdFormat
$creadPrec :: ReadPrec IdFormat
readList :: ReadS [IdFormat]
$creadList :: ReadS [IdFormat]
readsPrec :: Int -> ReadS IdFormat
$creadsPrec :: Int -> ReadS IdFormat
Prelude.Read, Int -> IdFormat -> ShowS
[IdFormat] -> ShowS
IdFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdFormat] -> ShowS
$cshowList :: [IdFormat] -> ShowS
show :: IdFormat -> String
$cshow :: IdFormat -> String
showsPrec :: Int -> IdFormat -> ShowS
$cshowsPrec :: Int -> IdFormat -> ShowS
Prelude.Show, forall x. Rep IdFormat x -> IdFormat
forall x. IdFormat -> Rep IdFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdFormat x -> IdFormat
$cfrom :: forall x. IdFormat -> Rep IdFormat x
Prelude.Generic)

-- |
-- Create a value of 'IdFormat' 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:
--
-- 'deadline', 'idFormat_deadline' - The date in UTC at which you are permanently switched over to using
-- longer IDs. If a deadline is not yet available for this resource type,
-- this field is not returned.
--
-- 'resource', 'idFormat_resource' - The type of resource.
--
-- 'useLongIds', 'idFormat_useLongIds' - Indicates whether longer IDs (17-character IDs) are enabled for the
-- resource.
newIdFormat ::
  IdFormat
newIdFormat :: IdFormat
newIdFormat =
  IdFormat'
    { $sel:deadline:IdFormat' :: Maybe ISO8601
deadline = forall a. Maybe a
Prelude.Nothing,
      $sel:resource:IdFormat' :: Maybe Text
resource = forall a. Maybe a
Prelude.Nothing,
      $sel:useLongIds:IdFormat' :: Maybe Bool
useLongIds = forall a. Maybe a
Prelude.Nothing
    }

-- | The date in UTC at which you are permanently switched over to using
-- longer IDs. If a deadline is not yet available for this resource type,
-- this field is not returned.
idFormat_deadline :: Lens.Lens' IdFormat (Prelude.Maybe Prelude.UTCTime)
idFormat_deadline :: Lens' IdFormat (Maybe UTCTime)
idFormat_deadline = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdFormat' {Maybe ISO8601
deadline :: Maybe ISO8601
$sel:deadline:IdFormat' :: IdFormat -> Maybe ISO8601
deadline} -> Maybe ISO8601
deadline) (\s :: IdFormat
s@IdFormat' {} Maybe ISO8601
a -> IdFormat
s {$sel:deadline:IdFormat' :: Maybe ISO8601
deadline = Maybe ISO8601
a} :: IdFormat) 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 type of resource.
idFormat_resource :: Lens.Lens' IdFormat (Prelude.Maybe Prelude.Text)
idFormat_resource :: Lens' IdFormat (Maybe Text)
idFormat_resource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdFormat' {Maybe Text
resource :: Maybe Text
$sel:resource:IdFormat' :: IdFormat -> Maybe Text
resource} -> Maybe Text
resource) (\s :: IdFormat
s@IdFormat' {} Maybe Text
a -> IdFormat
s {$sel:resource:IdFormat' :: Maybe Text
resource = Maybe Text
a} :: IdFormat)

-- | Indicates whether longer IDs (17-character IDs) are enabled for the
-- resource.
idFormat_useLongIds :: Lens.Lens' IdFormat (Prelude.Maybe Prelude.Bool)
idFormat_useLongIds :: Lens' IdFormat (Maybe Bool)
idFormat_useLongIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdFormat' {Maybe Bool
useLongIds :: Maybe Bool
$sel:useLongIds:IdFormat' :: IdFormat -> Maybe Bool
useLongIds} -> Maybe Bool
useLongIds) (\s :: IdFormat
s@IdFormat' {} Maybe Bool
a -> IdFormat
s {$sel:useLongIds:IdFormat' :: Maybe Bool
useLongIds = Maybe Bool
a} :: IdFormat)

instance Data.FromXML IdFormat where
  parseXML :: [Node] -> Either String IdFormat
parseXML [Node]
x =
    Maybe ISO8601 -> Maybe Text -> Maybe Bool -> IdFormat
IdFormat'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"deadline")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"resource")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"useLongIds")

instance Prelude.Hashable IdFormat where
  hashWithSalt :: Int -> IdFormat -> Int
hashWithSalt Int
_salt IdFormat' {Maybe Bool
Maybe Text
Maybe ISO8601
useLongIds :: Maybe Bool
resource :: Maybe Text
deadline :: Maybe ISO8601
$sel:useLongIds:IdFormat' :: IdFormat -> Maybe Bool
$sel:resource:IdFormat' :: IdFormat -> Maybe Text
$sel:deadline:IdFormat' :: IdFormat -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
deadline
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useLongIds

instance Prelude.NFData IdFormat where
  rnf :: IdFormat -> ()
rnf IdFormat' {Maybe Bool
Maybe Text
Maybe ISO8601
useLongIds :: Maybe Bool
resource :: Maybe Text
deadline :: Maybe ISO8601
$sel:useLongIds:IdFormat' :: IdFormat -> Maybe Bool
$sel:resource:IdFormat' :: IdFormat -> Maybe Text
$sel:deadline:IdFormat' :: IdFormat -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
deadline
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
useLongIds