{-# 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.Lightsail.Types.BucketState
-- 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.Lightsail.Types.BucketState where

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

-- | Describes the state of an Amazon Lightsail bucket.
--
-- /See:/ 'newBucketState' smart constructor.
data BucketState = BucketState'
  { -- | The state code of the bucket.
    --
    -- The following codes are possible:
    --
    -- -   @OK@ - The bucket is in a running state.
    --
    -- -   @Unknown@ - Creation of the bucket might have timed-out. You might
    --     want to delete the bucket and create a new one.
    BucketState -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | A message that describes the state of the bucket.
    BucketState -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (BucketState -> BucketState -> Bool
(BucketState -> BucketState -> Bool)
-> (BucketState -> BucketState -> Bool) -> Eq BucketState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketState -> BucketState -> Bool
$c/= :: BucketState -> BucketState -> Bool
== :: BucketState -> BucketState -> Bool
$c== :: BucketState -> BucketState -> Bool
Prelude.Eq, ReadPrec [BucketState]
ReadPrec BucketState
Int -> ReadS BucketState
ReadS [BucketState]
(Int -> ReadS BucketState)
-> ReadS [BucketState]
-> ReadPrec BucketState
-> ReadPrec [BucketState]
-> Read BucketState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketState]
$creadListPrec :: ReadPrec [BucketState]
readPrec :: ReadPrec BucketState
$creadPrec :: ReadPrec BucketState
readList :: ReadS [BucketState]
$creadList :: ReadS [BucketState]
readsPrec :: Int -> ReadS BucketState
$creadsPrec :: Int -> ReadS BucketState
Prelude.Read, Int -> BucketState -> ShowS
[BucketState] -> ShowS
BucketState -> String
(Int -> BucketState -> ShowS)
-> (BucketState -> String)
-> ([BucketState] -> ShowS)
-> Show BucketState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketState] -> ShowS
$cshowList :: [BucketState] -> ShowS
show :: BucketState -> String
$cshow :: BucketState -> String
showsPrec :: Int -> BucketState -> ShowS
$cshowsPrec :: Int -> BucketState -> ShowS
Prelude.Show, (forall x. BucketState -> Rep BucketState x)
-> (forall x. Rep BucketState x -> BucketState)
-> Generic BucketState
forall x. Rep BucketState x -> BucketState
forall x. BucketState -> Rep BucketState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketState x -> BucketState
$cfrom :: forall x. BucketState -> Rep BucketState x
Prelude.Generic)

-- |
-- Create a value of 'BucketState' 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:
--
-- 'code', 'bucketState_code' - The state code of the bucket.
--
-- The following codes are possible:
--
-- -   @OK@ - The bucket is in a running state.
--
-- -   @Unknown@ - Creation of the bucket might have timed-out. You might
--     want to delete the bucket and create a new one.
--
-- 'message', 'bucketState_message' - A message that describes the state of the bucket.
newBucketState ::
  BucketState
newBucketState :: BucketState
newBucketState =
  BucketState' :: Maybe Text -> Maybe Text -> BucketState
BucketState'
    { $sel:code:BucketState' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:BucketState' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The state code of the bucket.
--
-- The following codes are possible:
--
-- -   @OK@ - The bucket is in a running state.
--
-- -   @Unknown@ - Creation of the bucket might have timed-out. You might
--     want to delete the bucket and create a new one.
bucketState_code :: Lens.Lens' BucketState (Prelude.Maybe Prelude.Text)
bucketState_code :: (Maybe Text -> f (Maybe Text)) -> BucketState -> f BucketState
bucketState_code = (BucketState -> Maybe Text)
-> (BucketState -> Maybe Text -> BucketState)
-> Lens BucketState BucketState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketState' {Maybe Text
code :: Maybe Text
$sel:code:BucketState' :: BucketState -> Maybe Text
code} -> Maybe Text
code) (\s :: BucketState
s@BucketState' {} Maybe Text
a -> BucketState
s {$sel:code:BucketState' :: Maybe Text
code = Maybe Text
a} :: BucketState)

-- | A message that describes the state of the bucket.
bucketState_message :: Lens.Lens' BucketState (Prelude.Maybe Prelude.Text)
bucketState_message :: (Maybe Text -> f (Maybe Text)) -> BucketState -> f BucketState
bucketState_message = (BucketState -> Maybe Text)
-> (BucketState -> Maybe Text -> BucketState)
-> Lens BucketState BucketState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketState' {Maybe Text
message :: Maybe Text
$sel:message:BucketState' :: BucketState -> Maybe Text
message} -> Maybe Text
message) (\s :: BucketState
s@BucketState' {} Maybe Text
a -> BucketState
s {$sel:message:BucketState' :: Maybe Text
message = Maybe Text
a} :: BucketState)

instance Core.FromJSON BucketState where
  parseJSON :: Value -> Parser BucketState
parseJSON =
    String
-> (Object -> Parser BucketState) -> Value -> Parser BucketState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BucketState"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> BucketState
BucketState'
            (Maybe Text -> Maybe Text -> BucketState)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BucketState)
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
"code")
            Parser (Maybe Text -> BucketState)
-> Parser (Maybe Text) -> Parser BucketState
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
"message")
      )

instance Prelude.Hashable BucketState

instance Prelude.NFData BucketState