{-# 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.Support.Types.Category
-- 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.Support.Types.Category where

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

-- | A JSON-formatted name\/value pair that represents the category name and
-- category code of the problem, selected from the DescribeServices
-- response for each AWS service.
--
-- /See:/ 'newCategory' smart constructor.
data Category = Category'
  { -- | The category name for the support case.
    Category -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The category code for the support case.
    Category -> Maybe Text
code :: Prelude.Maybe Prelude.Text
  }
  deriving (Category -> Category -> Bool
(Category -> Category -> Bool)
-> (Category -> Category -> Bool) -> Eq Category
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Category -> Category -> Bool
$c/= :: Category -> Category -> Bool
== :: Category -> Category -> Bool
$c== :: Category -> Category -> Bool
Prelude.Eq, ReadPrec [Category]
ReadPrec Category
Int -> ReadS Category
ReadS [Category]
(Int -> ReadS Category)
-> ReadS [Category]
-> ReadPrec Category
-> ReadPrec [Category]
-> Read Category
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Category]
$creadListPrec :: ReadPrec [Category]
readPrec :: ReadPrec Category
$creadPrec :: ReadPrec Category
readList :: ReadS [Category]
$creadList :: ReadS [Category]
readsPrec :: Int -> ReadS Category
$creadsPrec :: Int -> ReadS Category
Prelude.Read, Int -> Category -> ShowS
[Category] -> ShowS
Category -> String
(Int -> Category -> ShowS)
-> (Category -> String) -> ([Category] -> ShowS) -> Show Category
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Category] -> ShowS
$cshowList :: [Category] -> ShowS
show :: Category -> String
$cshow :: Category -> String
showsPrec :: Int -> Category -> ShowS
$cshowsPrec :: Int -> Category -> ShowS
Prelude.Show, (forall x. Category -> Rep Category x)
-> (forall x. Rep Category x -> Category) -> Generic Category
forall x. Rep Category x -> Category
forall x. Category -> Rep Category x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Category x -> Category
$cfrom :: forall x. Category -> Rep Category x
Prelude.Generic)

-- |
-- Create a value of 'Category' 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:
--
-- 'name', 'category_name' - The category name for the support case.
--
-- 'code', 'category_code' - The category code for the support case.
newCategory ::
  Category
newCategory :: Category
newCategory =
  Category' :: Maybe Text -> Maybe Text -> Category
Category'
    { $sel:name:Category' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:code:Category' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The category name for the support case.
category_name :: Lens.Lens' Category (Prelude.Maybe Prelude.Text)
category_name :: (Maybe Text -> f (Maybe Text)) -> Category -> f Category
category_name = (Category -> Maybe Text)
-> (Category -> Maybe Text -> Category)
-> Lens Category Category (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Category' {Maybe Text
name :: Maybe Text
$sel:name:Category' :: Category -> Maybe Text
name} -> Maybe Text
name) (\s :: Category
s@Category' {} Maybe Text
a -> Category
s {$sel:name:Category' :: Maybe Text
name = Maybe Text
a} :: Category)

-- | The category code for the support case.
category_code :: Lens.Lens' Category (Prelude.Maybe Prelude.Text)
category_code :: (Maybe Text -> f (Maybe Text)) -> Category -> f Category
category_code = (Category -> Maybe Text)
-> (Category -> Maybe Text -> Category)
-> Lens Category Category (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Category' {Maybe Text
code :: Maybe Text
$sel:code:Category' :: Category -> Maybe Text
code} -> Maybe Text
code) (\s :: Category
s@Category' {} Maybe Text
a -> Category
s {$sel:code:Category' :: Maybe Text
code = Maybe Text
a} :: Category)

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

instance Prelude.Hashable Category

instance Prelude.NFData Category