{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateCase
-- 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)
--
-- Creates a case in the AWS Support Center. This operation is similar to
-- how you create a case in the AWS Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page.
--
-- The AWS Support API doesn\'t support requesting service limit increases.
-- You can submit a service limit increase in the following ways:
--
-- -   Submit a request from the AWS Support Center
--     <https://console.aws.amazon.com/support/home#/case/create Create Case>
--     page.
--
-- -   Use the Service Quotas
--     <https://docs.aws.amazon.com/servicequotas/2019-06-24/apireference/API_RequestServiceQuotaIncrease.html RequestServiceQuotaIncrease>
--     operation.
--
-- A successful @CreateCase@ request returns an AWS Support case number.
-- You can use the DescribeCases operation and specify the case number to
-- get existing AWS Support cases. After you create a case, use the
-- AddCommunicationToCase operation to add additional communication or
-- attachments to an existing case.
--
-- The @caseId@ is separate from the @displayId@ that appears in the
-- <https://console.aws.amazon.com/support AWS Support Center>. Use the
-- DescribeCases operation to get the @displayId@.
--
-- -   You must have a Business or Enterprise Support plan to use the AWS
--     Support API.
--
-- -   If you call the AWS Support API from an account that does not have a
--     Business or Enterprise Support plan, the
--     @SubscriptionRequiredException@ error message appears. For
--     information about changing your support plan, see
--     <http://aws.amazon.com/premiumsupport/ AWS Support>.
module Amazonka.Support.CreateCase
  ( -- * Creating a Request
    CreateCase (..),
    newCreateCase,

    -- * Request Lenses
    createCase_severityCode,
    createCase_issueType,
    createCase_ccEmailAddresses,
    createCase_language,
    createCase_categoryCode,
    createCase_serviceCode,
    createCase_attachmentSetId,
    createCase_subject,
    createCase_communicationBody,

    -- * Destructuring the Response
    CreateCaseResponse (..),
    newCreateCaseResponse,

    -- * Response Lenses
    createCaseResponse_caseId,
    createCaseResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Support.Types

-- | /See:/ 'newCreateCase' smart constructor.
data CreateCase = CreateCase'
  { -- | A value that indicates the urgency of the case. This value determines
    -- the response time according to your service level agreement with AWS
    -- Support. You can use the DescribeSeverityLevels operation to get the
    -- possible values for @severityCode@.
    --
    -- For more information, see SeverityLevel and
    -- <https://docs.aws.amazon.com/awssupport/latest/user/getting-started.html#choosing-severity Choosing a Severity>
    -- in the /AWS Support User Guide/.
    --
    -- The availability of severity levels depends on the support plan for the
    -- AWS account.
    CreateCase -> Maybe Text
severityCode :: Prelude.Maybe Prelude.Text,
    -- | The type of issue for the case. You can specify @customer-service@ or
    -- @technical@. If you don\'t specify a value, the default is @technical@.
    CreateCase -> Maybe Text
issueType :: Prelude.Maybe Prelude.Text,
    -- | A list of email addresses that AWS Support copies on case
    -- correspondence. AWS Support identifies the account that creates the case
    -- when you specify your AWS credentials in an HTTP POST method or use the
    -- <http://aws.amazon.com/tools/ AWS SDKs>.
    CreateCase -> Maybe [Text]
ccEmailAddresses :: Prelude.Maybe [Prelude.Text],
    -- | The language in which AWS Support handles the case. You must specify the
    -- ISO 639-1 code for the @language@ parameter if you want support in that
    -- language. Currently, English (\"en\") and Japanese (\"ja\") are
    -- supported.
    CreateCase -> Maybe Text
language :: Prelude.Maybe Prelude.Text,
    -- | The category of problem for the support case. You also use the
    -- DescribeServices operation to get the category code for a service. Each
    -- AWS service defines its own set of category codes.
    CreateCase -> Maybe Text
categoryCode :: Prelude.Maybe Prelude.Text,
    -- | The code for the AWS service. You can use the DescribeServices operation
    -- to get the possible @serviceCode@ values.
    CreateCase -> Maybe Text
serviceCode :: Prelude.Maybe Prelude.Text,
    -- | The ID of a set of one or more attachments for the case. Create the set
    -- by using the AddAttachmentsToSet operation.
    CreateCase -> Maybe Text
attachmentSetId :: Prelude.Maybe Prelude.Text,
    -- | The title of the support case. The title appears in the __Subject__
    -- field on the AWS Support Center
    -- <https://console.aws.amazon.com/support/home#/case/create Create Case>
    -- page.
    CreateCase -> Text
subject :: Prelude.Text,
    -- | The communication body text that describes the issue. This text appears
    -- in the __Description__ field on the AWS Support Center
    -- <https://console.aws.amazon.com/support/home#/case/create Create Case>
    -- page.
    CreateCase -> Text
communicationBody :: Prelude.Text
  }
  deriving (CreateCase -> CreateCase -> Bool
(CreateCase -> CreateCase -> Bool)
-> (CreateCase -> CreateCase -> Bool) -> Eq CreateCase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCase -> CreateCase -> Bool
$c/= :: CreateCase -> CreateCase -> Bool
== :: CreateCase -> CreateCase -> Bool
$c== :: CreateCase -> CreateCase -> Bool
Prelude.Eq, ReadPrec [CreateCase]
ReadPrec CreateCase
Int -> ReadS CreateCase
ReadS [CreateCase]
(Int -> ReadS CreateCase)
-> ReadS [CreateCase]
-> ReadPrec CreateCase
-> ReadPrec [CreateCase]
-> Read CreateCase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCase]
$creadListPrec :: ReadPrec [CreateCase]
readPrec :: ReadPrec CreateCase
$creadPrec :: ReadPrec CreateCase
readList :: ReadS [CreateCase]
$creadList :: ReadS [CreateCase]
readsPrec :: Int -> ReadS CreateCase
$creadsPrec :: Int -> ReadS CreateCase
Prelude.Read, Int -> CreateCase -> ShowS
[CreateCase] -> ShowS
CreateCase -> String
(Int -> CreateCase -> ShowS)
-> (CreateCase -> String)
-> ([CreateCase] -> ShowS)
-> Show CreateCase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCase] -> ShowS
$cshowList :: [CreateCase] -> ShowS
show :: CreateCase -> String
$cshow :: CreateCase -> String
showsPrec :: Int -> CreateCase -> ShowS
$cshowsPrec :: Int -> CreateCase -> ShowS
Prelude.Show, (forall x. CreateCase -> Rep CreateCase x)
-> (forall x. Rep CreateCase x -> CreateCase) -> Generic CreateCase
forall x. Rep CreateCase x -> CreateCase
forall x. CreateCase -> Rep CreateCase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCase x -> CreateCase
$cfrom :: forall x. CreateCase -> Rep CreateCase x
Prelude.Generic)

-- |
-- Create a value of 'CreateCase' 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:
--
-- 'severityCode', 'createCase_severityCode' - A value that indicates the urgency of the case. This value determines
-- the response time according to your service level agreement with AWS
-- Support. You can use the DescribeSeverityLevels operation to get the
-- possible values for @severityCode@.
--
-- For more information, see SeverityLevel and
-- <https://docs.aws.amazon.com/awssupport/latest/user/getting-started.html#choosing-severity Choosing a Severity>
-- in the /AWS Support User Guide/.
--
-- The availability of severity levels depends on the support plan for the
-- AWS account.
--
-- 'issueType', 'createCase_issueType' - The type of issue for the case. You can specify @customer-service@ or
-- @technical@. If you don\'t specify a value, the default is @technical@.
--
-- 'ccEmailAddresses', 'createCase_ccEmailAddresses' - A list of email addresses that AWS Support copies on case
-- correspondence. AWS Support identifies the account that creates the case
-- when you specify your AWS credentials in an HTTP POST method or use the
-- <http://aws.amazon.com/tools/ AWS SDKs>.
--
-- 'language', 'createCase_language' - The language in which AWS Support handles the case. You must specify the
-- ISO 639-1 code for the @language@ parameter if you want support in that
-- language. Currently, English (\"en\") and Japanese (\"ja\") are
-- supported.
--
-- 'categoryCode', 'createCase_categoryCode' - The category of problem for the support case. You also use the
-- DescribeServices operation to get the category code for a service. Each
-- AWS service defines its own set of category codes.
--
-- 'serviceCode', 'createCase_serviceCode' - The code for the AWS service. You can use the DescribeServices operation
-- to get the possible @serviceCode@ values.
--
-- 'attachmentSetId', 'createCase_attachmentSetId' - The ID of a set of one or more attachments for the case. Create the set
-- by using the AddAttachmentsToSet operation.
--
-- 'subject', 'createCase_subject' - The title of the support case. The title appears in the __Subject__
-- field on the AWS Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page.
--
-- 'communicationBody', 'createCase_communicationBody' - The communication body text that describes the issue. This text appears
-- in the __Description__ field on the AWS Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page.
newCreateCase ::
  -- | 'subject'
  Prelude.Text ->
  -- | 'communicationBody'
  Prelude.Text ->
  CreateCase
newCreateCase :: Text -> Text -> CreateCase
newCreateCase Text
pSubject_ Text
pCommunicationBody_ =
  CreateCase' :: Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> CreateCase
CreateCase'
    { $sel:severityCode:CreateCase' :: Maybe Text
severityCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:issueType:CreateCase' :: Maybe Text
issueType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ccEmailAddresses:CreateCase' :: Maybe [Text]
ccEmailAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:language:CreateCase' :: Maybe Text
language = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:categoryCode:CreateCase' :: Maybe Text
categoryCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceCode:CreateCase' :: Maybe Text
serviceCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attachmentSetId:CreateCase' :: Maybe Text
attachmentSetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subject:CreateCase' :: Text
subject = Text
pSubject_,
      $sel:communicationBody:CreateCase' :: Text
communicationBody = Text
pCommunicationBody_
    }

-- | A value that indicates the urgency of the case. This value determines
-- the response time according to your service level agreement with AWS
-- Support. You can use the DescribeSeverityLevels operation to get the
-- possible values for @severityCode@.
--
-- For more information, see SeverityLevel and
-- <https://docs.aws.amazon.com/awssupport/latest/user/getting-started.html#choosing-severity Choosing a Severity>
-- in the /AWS Support User Guide/.
--
-- The availability of severity levels depends on the support plan for the
-- AWS account.
createCase_severityCode :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_severityCode :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_severityCode = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
severityCode :: Maybe Text
$sel:severityCode:CreateCase' :: CreateCase -> Maybe Text
severityCode} -> Maybe Text
severityCode) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:severityCode:CreateCase' :: Maybe Text
severityCode = Maybe Text
a} :: CreateCase)

-- | The type of issue for the case. You can specify @customer-service@ or
-- @technical@. If you don\'t specify a value, the default is @technical@.
createCase_issueType :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_issueType :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_issueType = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
issueType :: Maybe Text
$sel:issueType:CreateCase' :: CreateCase -> Maybe Text
issueType} -> Maybe Text
issueType) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:issueType:CreateCase' :: Maybe Text
issueType = Maybe Text
a} :: CreateCase)

-- | A list of email addresses that AWS Support copies on case
-- correspondence. AWS Support identifies the account that creates the case
-- when you specify your AWS credentials in an HTTP POST method or use the
-- <http://aws.amazon.com/tools/ AWS SDKs>.
createCase_ccEmailAddresses :: Lens.Lens' CreateCase (Prelude.Maybe [Prelude.Text])
createCase_ccEmailAddresses :: (Maybe [Text] -> f (Maybe [Text])) -> CreateCase -> f CreateCase
createCase_ccEmailAddresses = (CreateCase -> Maybe [Text])
-> (CreateCase -> Maybe [Text] -> CreateCase)
-> Lens CreateCase CreateCase (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe [Text]
ccEmailAddresses :: Maybe [Text]
$sel:ccEmailAddresses:CreateCase' :: CreateCase -> Maybe [Text]
ccEmailAddresses} -> Maybe [Text]
ccEmailAddresses) (\s :: CreateCase
s@CreateCase' {} Maybe [Text]
a -> CreateCase
s {$sel:ccEmailAddresses:CreateCase' :: Maybe [Text]
ccEmailAddresses = Maybe [Text]
a} :: CreateCase) ((Maybe [Text] -> f (Maybe [Text])) -> CreateCase -> f CreateCase)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateCase
-> f CreateCase
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

-- | The language in which AWS Support handles the case. You must specify the
-- ISO 639-1 code for the @language@ parameter if you want support in that
-- language. Currently, English (\"en\") and Japanese (\"ja\") are
-- supported.
createCase_language :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_language :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_language = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
language :: Maybe Text
$sel:language:CreateCase' :: CreateCase -> Maybe Text
language} -> Maybe Text
language) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:language:CreateCase' :: Maybe Text
language = Maybe Text
a} :: CreateCase)

-- | The category of problem for the support case. You also use the
-- DescribeServices operation to get the category code for a service. Each
-- AWS service defines its own set of category codes.
createCase_categoryCode :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_categoryCode :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_categoryCode = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
categoryCode :: Maybe Text
$sel:categoryCode:CreateCase' :: CreateCase -> Maybe Text
categoryCode} -> Maybe Text
categoryCode) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:categoryCode:CreateCase' :: Maybe Text
categoryCode = Maybe Text
a} :: CreateCase)

-- | The code for the AWS service. You can use the DescribeServices operation
-- to get the possible @serviceCode@ values.
createCase_serviceCode :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_serviceCode :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_serviceCode = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
serviceCode :: Maybe Text
$sel:serviceCode:CreateCase' :: CreateCase -> Maybe Text
serviceCode} -> Maybe Text
serviceCode) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:serviceCode:CreateCase' :: Maybe Text
serviceCode = Maybe Text
a} :: CreateCase)

-- | The ID of a set of one or more attachments for the case. Create the set
-- by using the AddAttachmentsToSet operation.
createCase_attachmentSetId :: Lens.Lens' CreateCase (Prelude.Maybe Prelude.Text)
createCase_attachmentSetId :: (Maybe Text -> f (Maybe Text)) -> CreateCase -> f CreateCase
createCase_attachmentSetId = (CreateCase -> Maybe Text)
-> (CreateCase -> Maybe Text -> CreateCase)
-> Lens CreateCase CreateCase (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Maybe Text
attachmentSetId :: Maybe Text
$sel:attachmentSetId:CreateCase' :: CreateCase -> Maybe Text
attachmentSetId} -> Maybe Text
attachmentSetId) (\s :: CreateCase
s@CreateCase' {} Maybe Text
a -> CreateCase
s {$sel:attachmentSetId:CreateCase' :: Maybe Text
attachmentSetId = Maybe Text
a} :: CreateCase)

-- | The title of the support case. The title appears in the __Subject__
-- field on the AWS Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page.
createCase_subject :: Lens.Lens' CreateCase Prelude.Text
createCase_subject :: (Text -> f Text) -> CreateCase -> f CreateCase
createCase_subject = (CreateCase -> Text)
-> (CreateCase -> Text -> CreateCase)
-> Lens CreateCase CreateCase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Text
subject :: Text
$sel:subject:CreateCase' :: CreateCase -> Text
subject} -> Text
subject) (\s :: CreateCase
s@CreateCase' {} Text
a -> CreateCase
s {$sel:subject:CreateCase' :: Text
subject = Text
a} :: CreateCase)

-- | The communication body text that describes the issue. This text appears
-- in the __Description__ field on the AWS Support Center
-- <https://console.aws.amazon.com/support/home#/case/create Create Case>
-- page.
createCase_communicationBody :: Lens.Lens' CreateCase Prelude.Text
createCase_communicationBody :: (Text -> f Text) -> CreateCase -> f CreateCase
createCase_communicationBody = (CreateCase -> Text)
-> (CreateCase -> Text -> CreateCase)
-> Lens CreateCase CreateCase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCase' {Text
communicationBody :: Text
$sel:communicationBody:CreateCase' :: CreateCase -> Text
communicationBody} -> Text
communicationBody) (\s :: CreateCase
s@CreateCase' {} Text
a -> CreateCase
s {$sel:communicationBody:CreateCase' :: Text
communicationBody = Text
a} :: CreateCase)

instance Core.AWSRequest CreateCase where
  type AWSResponse CreateCase = CreateCaseResponse
  request :: CreateCase -> Request CreateCase
request = Service -> CreateCase -> Request CreateCase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateCase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateCase))
-> Logger
-> Service
-> Proxy CreateCase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCase)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> CreateCaseResponse
CreateCaseResponse'
            (Maybe Text -> Int -> CreateCaseResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateCaseResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"caseId")
            Either String (Int -> CreateCaseResponse)
-> Either String Int -> Either String CreateCaseResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateCase

instance Prelude.NFData CreateCase

instance Core.ToHeaders CreateCase where
  toHeaders :: CreateCase -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateCase -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSSupport_20130415.CreateCase" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateCase where
  toJSON :: CreateCase -> Value
toJSON CreateCase' {Maybe [Text]
Maybe Text
Text
communicationBody :: Text
subject :: Text
attachmentSetId :: Maybe Text
serviceCode :: Maybe Text
categoryCode :: Maybe Text
language :: Maybe Text
ccEmailAddresses :: Maybe [Text]
issueType :: Maybe Text
severityCode :: Maybe Text
$sel:communicationBody:CreateCase' :: CreateCase -> Text
$sel:subject:CreateCase' :: CreateCase -> Text
$sel:attachmentSetId:CreateCase' :: CreateCase -> Maybe Text
$sel:serviceCode:CreateCase' :: CreateCase -> Maybe Text
$sel:categoryCode:CreateCase' :: CreateCase -> Maybe Text
$sel:language:CreateCase' :: CreateCase -> Maybe Text
$sel:ccEmailAddresses:CreateCase' :: CreateCase -> Maybe [Text]
$sel:issueType:CreateCase' :: CreateCase -> Maybe Text
$sel:severityCode:CreateCase' :: CreateCase -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"severityCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
severityCode,
            (Text
"issueType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
issueType,
            (Text
"ccEmailAddresses" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ccEmailAddresses,
            (Text
"language" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
language,
            (Text
"categoryCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
categoryCode,
            (Text
"serviceCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serviceCode,
            (Text
"attachmentSetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attachmentSetId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"subject" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
subject),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"communicationBody" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
communicationBody)
          ]
      )

instance Core.ToPath CreateCase where
  toPath :: CreateCase -> ByteString
toPath = ByteString -> CreateCase -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateCase where
  toQuery :: CreateCase -> QueryString
toQuery = QueryString -> CreateCase -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | The support case ID returned by a successful completion of the
-- CreateCase operation.
--
-- /See:/ 'newCreateCaseResponse' smart constructor.
data CreateCaseResponse = CreateCaseResponse'
  { -- | The support case ID requested or returned in the call. The case ID is an
    -- alphanumeric string in the following format:
    -- case-/12345678910-2013-c4c1d2bf33c5cf47/
    CreateCaseResponse -> Maybe Text
caseId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateCaseResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateCaseResponse -> CreateCaseResponse -> Bool
(CreateCaseResponse -> CreateCaseResponse -> Bool)
-> (CreateCaseResponse -> CreateCaseResponse -> Bool)
-> Eq CreateCaseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCaseResponse -> CreateCaseResponse -> Bool
$c/= :: CreateCaseResponse -> CreateCaseResponse -> Bool
== :: CreateCaseResponse -> CreateCaseResponse -> Bool
$c== :: CreateCaseResponse -> CreateCaseResponse -> Bool
Prelude.Eq, ReadPrec [CreateCaseResponse]
ReadPrec CreateCaseResponse
Int -> ReadS CreateCaseResponse
ReadS [CreateCaseResponse]
(Int -> ReadS CreateCaseResponse)
-> ReadS [CreateCaseResponse]
-> ReadPrec CreateCaseResponse
-> ReadPrec [CreateCaseResponse]
-> Read CreateCaseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCaseResponse]
$creadListPrec :: ReadPrec [CreateCaseResponse]
readPrec :: ReadPrec CreateCaseResponse
$creadPrec :: ReadPrec CreateCaseResponse
readList :: ReadS [CreateCaseResponse]
$creadList :: ReadS [CreateCaseResponse]
readsPrec :: Int -> ReadS CreateCaseResponse
$creadsPrec :: Int -> ReadS CreateCaseResponse
Prelude.Read, Int -> CreateCaseResponse -> ShowS
[CreateCaseResponse] -> ShowS
CreateCaseResponse -> String
(Int -> CreateCaseResponse -> ShowS)
-> (CreateCaseResponse -> String)
-> ([CreateCaseResponse] -> ShowS)
-> Show CreateCaseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCaseResponse] -> ShowS
$cshowList :: [CreateCaseResponse] -> ShowS
show :: CreateCaseResponse -> String
$cshow :: CreateCaseResponse -> String
showsPrec :: Int -> CreateCaseResponse -> ShowS
$cshowsPrec :: Int -> CreateCaseResponse -> ShowS
Prelude.Show, (forall x. CreateCaseResponse -> Rep CreateCaseResponse x)
-> (forall x. Rep CreateCaseResponse x -> CreateCaseResponse)
-> Generic CreateCaseResponse
forall x. Rep CreateCaseResponse x -> CreateCaseResponse
forall x. CreateCaseResponse -> Rep CreateCaseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCaseResponse x -> CreateCaseResponse
$cfrom :: forall x. CreateCaseResponse -> Rep CreateCaseResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateCaseResponse' 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:
--
-- 'caseId', 'createCaseResponse_caseId' - The support case ID requested or returned in the call. The case ID is an
-- alphanumeric string in the following format:
-- case-/12345678910-2013-c4c1d2bf33c5cf47/
--
-- 'httpStatus', 'createCaseResponse_httpStatus' - The response's http status code.
newCreateCaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateCaseResponse
newCreateCaseResponse :: Int -> CreateCaseResponse
newCreateCaseResponse Int
pHttpStatus_ =
  CreateCaseResponse' :: Maybe Text -> Int -> CreateCaseResponse
CreateCaseResponse'
    { $sel:caseId:CreateCaseResponse' :: Maybe Text
caseId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateCaseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The support case ID requested or returned in the call. The case ID is an
-- alphanumeric string in the following format:
-- case-/12345678910-2013-c4c1d2bf33c5cf47/
createCaseResponse_caseId :: Lens.Lens' CreateCaseResponse (Prelude.Maybe Prelude.Text)
createCaseResponse_caseId :: (Maybe Text -> f (Maybe Text))
-> CreateCaseResponse -> f CreateCaseResponse
createCaseResponse_caseId = (CreateCaseResponse -> Maybe Text)
-> (CreateCaseResponse -> Maybe Text -> CreateCaseResponse)
-> Lens
     CreateCaseResponse CreateCaseResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCaseResponse' {Maybe Text
caseId :: Maybe Text
$sel:caseId:CreateCaseResponse' :: CreateCaseResponse -> Maybe Text
caseId} -> Maybe Text
caseId) (\s :: CreateCaseResponse
s@CreateCaseResponse' {} Maybe Text
a -> CreateCaseResponse
s {$sel:caseId:CreateCaseResponse' :: Maybe Text
caseId = Maybe Text
a} :: CreateCaseResponse)

-- | The response's http status code.
createCaseResponse_httpStatus :: Lens.Lens' CreateCaseResponse Prelude.Int
createCaseResponse_httpStatus :: (Int -> f Int) -> CreateCaseResponse -> f CreateCaseResponse
createCaseResponse_httpStatus = (CreateCaseResponse -> Int)
-> (CreateCaseResponse -> Int -> CreateCaseResponse)
-> Lens CreateCaseResponse CreateCaseResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCaseResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCaseResponse' :: CreateCaseResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCaseResponse
s@CreateCaseResponse' {} Int
a -> CreateCaseResponse
s {$sel:httpStatus:CreateCaseResponse' :: Int
httpStatus = Int
a} :: CreateCaseResponse)

instance Prelude.NFData CreateCaseResponse