{-# 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.ResolveCase
-- 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)
--
-- Resolves a support case. This operation takes a @caseId@ and returns the
-- initial and final state of the case.
--
-- -   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.ResolveCase
  ( -- * Creating a Request
    ResolveCase (..),
    newResolveCase,

    -- * Request Lenses
    resolveCase_caseId,

    -- * Destructuring the Response
    ResolveCaseResponse (..),
    newResolveCaseResponse,

    -- * Response Lenses
    resolveCaseResponse_initialCaseStatus,
    resolveCaseResponse_finalCaseStatus,
    resolveCaseResponse_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:/ 'newResolveCase' smart constructor.
data ResolveCase = ResolveCase'
  { -- | The support case ID requested or returned in the call. The case ID is an
    -- alphanumeric string formatted as shown in this example:
    -- case-/12345678910-2013-c4c1d2bf33c5cf47/
    ResolveCase -> Maybe Text
caseId :: Prelude.Maybe Prelude.Text
  }
  deriving (ResolveCase -> ResolveCase -> Bool
(ResolveCase -> ResolveCase -> Bool)
-> (ResolveCase -> ResolveCase -> Bool) -> Eq ResolveCase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolveCase -> ResolveCase -> Bool
$c/= :: ResolveCase -> ResolveCase -> Bool
== :: ResolveCase -> ResolveCase -> Bool
$c== :: ResolveCase -> ResolveCase -> Bool
Prelude.Eq, ReadPrec [ResolveCase]
ReadPrec ResolveCase
Int -> ReadS ResolveCase
ReadS [ResolveCase]
(Int -> ReadS ResolveCase)
-> ReadS [ResolveCase]
-> ReadPrec ResolveCase
-> ReadPrec [ResolveCase]
-> Read ResolveCase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResolveCase]
$creadListPrec :: ReadPrec [ResolveCase]
readPrec :: ReadPrec ResolveCase
$creadPrec :: ReadPrec ResolveCase
readList :: ReadS [ResolveCase]
$creadList :: ReadS [ResolveCase]
readsPrec :: Int -> ReadS ResolveCase
$creadsPrec :: Int -> ReadS ResolveCase
Prelude.Read, Int -> ResolveCase -> ShowS
[ResolveCase] -> ShowS
ResolveCase -> String
(Int -> ResolveCase -> ShowS)
-> (ResolveCase -> String)
-> ([ResolveCase] -> ShowS)
-> Show ResolveCase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolveCase] -> ShowS
$cshowList :: [ResolveCase] -> ShowS
show :: ResolveCase -> String
$cshow :: ResolveCase -> String
showsPrec :: Int -> ResolveCase -> ShowS
$cshowsPrec :: Int -> ResolveCase -> ShowS
Prelude.Show, (forall x. ResolveCase -> Rep ResolveCase x)
-> (forall x. Rep ResolveCase x -> ResolveCase)
-> Generic ResolveCase
forall x. Rep ResolveCase x -> ResolveCase
forall x. ResolveCase -> Rep ResolveCase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResolveCase x -> ResolveCase
$cfrom :: forall x. ResolveCase -> Rep ResolveCase x
Prelude.Generic)

-- |
-- Create a value of 'ResolveCase' 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', 'resolveCase_caseId' - The support case ID requested or returned in the call. The case ID is an
-- alphanumeric string formatted as shown in this example:
-- case-/12345678910-2013-c4c1d2bf33c5cf47/
newResolveCase ::
  ResolveCase
newResolveCase :: ResolveCase
newResolveCase =
  ResolveCase' :: Maybe Text -> ResolveCase
ResolveCase' {$sel:caseId:ResolveCase' :: Maybe Text
caseId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

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

instance Core.AWSRequest ResolveCase where
  type AWSResponse ResolveCase = ResolveCaseResponse
  request :: ResolveCase -> Request ResolveCase
request = Service -> ResolveCase -> Request ResolveCase
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ResolveCase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResolveCase)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ResolveCase))
-> Logger
-> Service
-> Proxy ResolveCase
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResolveCase)))
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 -> Maybe Text -> Int -> ResolveCaseResponse
ResolveCaseResponse'
            (Maybe Text -> Maybe Text -> Int -> ResolveCaseResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> ResolveCaseResponse)
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
"initialCaseStatus")
            Either String (Maybe Text -> Int -> ResolveCaseResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ResolveCaseResponse)
forall (f :: * -> *) a b. Applicative f => 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
"finalCaseStatus")
            Either String (Int -> ResolveCaseResponse)
-> Either String Int -> Either String ResolveCaseResponse
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 ResolveCase

instance Prelude.NFData ResolveCase

instance Core.ToHeaders ResolveCase where
  toHeaders :: ResolveCase -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ResolveCase -> 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.ResolveCase" ::
                          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 ResolveCase where
  toJSON :: ResolveCase -> Value
toJSON ResolveCase' {Maybe Text
caseId :: Maybe Text
$sel:caseId:ResolveCase' :: ResolveCase -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"caseId" 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
caseId]
      )

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

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

-- | The status of the case returned by the ResolveCase operation.
--
-- /See:/ 'newResolveCaseResponse' smart constructor.
data ResolveCaseResponse = ResolveCaseResponse'
  { -- | The status of the case when the ResolveCase request was sent.
    ResolveCaseResponse -> Maybe Text
initialCaseStatus :: Prelude.Maybe Prelude.Text,
    -- | The status of the case after the ResolveCase request was processed.
    ResolveCaseResponse -> Maybe Text
finalCaseStatus :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ResolveCaseResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ResolveCaseResponse -> ResolveCaseResponse -> Bool
(ResolveCaseResponse -> ResolveCaseResponse -> Bool)
-> (ResolveCaseResponse -> ResolveCaseResponse -> Bool)
-> Eq ResolveCaseResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolveCaseResponse -> ResolveCaseResponse -> Bool
$c/= :: ResolveCaseResponse -> ResolveCaseResponse -> Bool
== :: ResolveCaseResponse -> ResolveCaseResponse -> Bool
$c== :: ResolveCaseResponse -> ResolveCaseResponse -> Bool
Prelude.Eq, ReadPrec [ResolveCaseResponse]
ReadPrec ResolveCaseResponse
Int -> ReadS ResolveCaseResponse
ReadS [ResolveCaseResponse]
(Int -> ReadS ResolveCaseResponse)
-> ReadS [ResolveCaseResponse]
-> ReadPrec ResolveCaseResponse
-> ReadPrec [ResolveCaseResponse]
-> Read ResolveCaseResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResolveCaseResponse]
$creadListPrec :: ReadPrec [ResolveCaseResponse]
readPrec :: ReadPrec ResolveCaseResponse
$creadPrec :: ReadPrec ResolveCaseResponse
readList :: ReadS [ResolveCaseResponse]
$creadList :: ReadS [ResolveCaseResponse]
readsPrec :: Int -> ReadS ResolveCaseResponse
$creadsPrec :: Int -> ReadS ResolveCaseResponse
Prelude.Read, Int -> ResolveCaseResponse -> ShowS
[ResolveCaseResponse] -> ShowS
ResolveCaseResponse -> String
(Int -> ResolveCaseResponse -> ShowS)
-> (ResolveCaseResponse -> String)
-> ([ResolveCaseResponse] -> ShowS)
-> Show ResolveCaseResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolveCaseResponse] -> ShowS
$cshowList :: [ResolveCaseResponse] -> ShowS
show :: ResolveCaseResponse -> String
$cshow :: ResolveCaseResponse -> String
showsPrec :: Int -> ResolveCaseResponse -> ShowS
$cshowsPrec :: Int -> ResolveCaseResponse -> ShowS
Prelude.Show, (forall x. ResolveCaseResponse -> Rep ResolveCaseResponse x)
-> (forall x. Rep ResolveCaseResponse x -> ResolveCaseResponse)
-> Generic ResolveCaseResponse
forall x. Rep ResolveCaseResponse x -> ResolveCaseResponse
forall x. ResolveCaseResponse -> Rep ResolveCaseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResolveCaseResponse x -> ResolveCaseResponse
$cfrom :: forall x. ResolveCaseResponse -> Rep ResolveCaseResponse x
Prelude.Generic)

-- |
-- Create a value of 'ResolveCaseResponse' 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:
--
-- 'initialCaseStatus', 'resolveCaseResponse_initialCaseStatus' - The status of the case when the ResolveCase request was sent.
--
-- 'finalCaseStatus', 'resolveCaseResponse_finalCaseStatus' - The status of the case after the ResolveCase request was processed.
--
-- 'httpStatus', 'resolveCaseResponse_httpStatus' - The response's http status code.
newResolveCaseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ResolveCaseResponse
newResolveCaseResponse :: Int -> ResolveCaseResponse
newResolveCaseResponse Int
pHttpStatus_ =
  ResolveCaseResponse' :: Maybe Text -> Maybe Text -> Int -> ResolveCaseResponse
ResolveCaseResponse'
    { $sel:initialCaseStatus:ResolveCaseResponse' :: Maybe Text
initialCaseStatus =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:finalCaseStatus:ResolveCaseResponse' :: Maybe Text
finalCaseStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ResolveCaseResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the case when the ResolveCase request was sent.
resolveCaseResponse_initialCaseStatus :: Lens.Lens' ResolveCaseResponse (Prelude.Maybe Prelude.Text)
resolveCaseResponse_initialCaseStatus :: (Maybe Text -> f (Maybe Text))
-> ResolveCaseResponse -> f ResolveCaseResponse
resolveCaseResponse_initialCaseStatus = (ResolveCaseResponse -> Maybe Text)
-> (ResolveCaseResponse -> Maybe Text -> ResolveCaseResponse)
-> Lens
     ResolveCaseResponse ResolveCaseResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolveCaseResponse' {Maybe Text
initialCaseStatus :: Maybe Text
$sel:initialCaseStatus:ResolveCaseResponse' :: ResolveCaseResponse -> Maybe Text
initialCaseStatus} -> Maybe Text
initialCaseStatus) (\s :: ResolveCaseResponse
s@ResolveCaseResponse' {} Maybe Text
a -> ResolveCaseResponse
s {$sel:initialCaseStatus:ResolveCaseResponse' :: Maybe Text
initialCaseStatus = Maybe Text
a} :: ResolveCaseResponse)

-- | The status of the case after the ResolveCase request was processed.
resolveCaseResponse_finalCaseStatus :: Lens.Lens' ResolveCaseResponse (Prelude.Maybe Prelude.Text)
resolveCaseResponse_finalCaseStatus :: (Maybe Text -> f (Maybe Text))
-> ResolveCaseResponse -> f ResolveCaseResponse
resolveCaseResponse_finalCaseStatus = (ResolveCaseResponse -> Maybe Text)
-> (ResolveCaseResponse -> Maybe Text -> ResolveCaseResponse)
-> Lens
     ResolveCaseResponse ResolveCaseResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolveCaseResponse' {Maybe Text
finalCaseStatus :: Maybe Text
$sel:finalCaseStatus:ResolveCaseResponse' :: ResolveCaseResponse -> Maybe Text
finalCaseStatus} -> Maybe Text
finalCaseStatus) (\s :: ResolveCaseResponse
s@ResolveCaseResponse' {} Maybe Text
a -> ResolveCaseResponse
s {$sel:finalCaseStatus:ResolveCaseResponse' :: Maybe Text
finalCaseStatus = Maybe Text
a} :: ResolveCaseResponse)

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

instance Prelude.NFData ResolveCaseResponse