{-# 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.Connect.DescribeInstance
-- 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)
--
-- This API is in preview release for Amazon Connect and is subject to
-- change.
--
-- Returns the current state of the specified instance identifier. It
-- tracks the instance while it is being created and returns an error
-- status, if applicable.
--
-- If an instance is not created successfully, the instance status reason
-- field returns details relevant to the reason. The instance in a failed
-- state is returned only for 24 hours after the CreateInstance API was
-- invoked.
module Amazonka.Connect.DescribeInstance
  ( -- * Creating a Request
    DescribeInstance (..),
    newDescribeInstance,

    -- * Request Lenses
    describeInstance_instanceId,

    -- * Destructuring the Response
    DescribeInstanceResponse (..),
    newDescribeInstanceResponse,

    -- * Response Lenses
    describeInstanceResponse_instance,
    describeInstanceResponse_httpStatus,
  )
where

import Amazonka.Connect.Types
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

-- | /See:/ 'newDescribeInstance' smart constructor.
data DescribeInstance = DescribeInstance'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    DescribeInstance -> Text
instanceId :: Prelude.Text
  }
  deriving (DescribeInstance -> DescribeInstance -> Bool
(DescribeInstance -> DescribeInstance -> Bool)
-> (DescribeInstance -> DescribeInstance -> Bool)
-> Eq DescribeInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInstance -> DescribeInstance -> Bool
$c/= :: DescribeInstance -> DescribeInstance -> Bool
== :: DescribeInstance -> DescribeInstance -> Bool
$c== :: DescribeInstance -> DescribeInstance -> Bool
Prelude.Eq, ReadPrec [DescribeInstance]
ReadPrec DescribeInstance
Int -> ReadS DescribeInstance
ReadS [DescribeInstance]
(Int -> ReadS DescribeInstance)
-> ReadS [DescribeInstance]
-> ReadPrec DescribeInstance
-> ReadPrec [DescribeInstance]
-> Read DescribeInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInstance]
$creadListPrec :: ReadPrec [DescribeInstance]
readPrec :: ReadPrec DescribeInstance
$creadPrec :: ReadPrec DescribeInstance
readList :: ReadS [DescribeInstance]
$creadList :: ReadS [DescribeInstance]
readsPrec :: Int -> ReadS DescribeInstance
$creadsPrec :: Int -> ReadS DescribeInstance
Prelude.Read, Int -> DescribeInstance -> ShowS
[DescribeInstance] -> ShowS
DescribeInstance -> String
(Int -> DescribeInstance -> ShowS)
-> (DescribeInstance -> String)
-> ([DescribeInstance] -> ShowS)
-> Show DescribeInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInstance] -> ShowS
$cshowList :: [DescribeInstance] -> ShowS
show :: DescribeInstance -> String
$cshow :: DescribeInstance -> String
showsPrec :: Int -> DescribeInstance -> ShowS
$cshowsPrec :: Int -> DescribeInstance -> ShowS
Prelude.Show, (forall x. DescribeInstance -> Rep DescribeInstance x)
-> (forall x. Rep DescribeInstance x -> DescribeInstance)
-> Generic DescribeInstance
forall x. Rep DescribeInstance x -> DescribeInstance
forall x. DescribeInstance -> Rep DescribeInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeInstance x -> DescribeInstance
$cfrom :: forall x. DescribeInstance -> Rep DescribeInstance x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInstance' 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:
--
-- 'instanceId', 'describeInstance_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newDescribeInstance ::
  -- | 'instanceId'
  Prelude.Text ->
  DescribeInstance
newDescribeInstance :: Text -> DescribeInstance
newDescribeInstance Text
pInstanceId_ =
  DescribeInstance' :: Text -> DescribeInstance
DescribeInstance' {$sel:instanceId:DescribeInstance' :: Text
instanceId = Text
pInstanceId_}

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
describeInstance_instanceId :: Lens.Lens' DescribeInstance Prelude.Text
describeInstance_instanceId :: (Text -> f Text) -> DescribeInstance -> f DescribeInstance
describeInstance_instanceId = (DescribeInstance -> Text)
-> (DescribeInstance -> Text -> DescribeInstance)
-> Lens DescribeInstance DescribeInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstance' {Text
instanceId :: Text
$sel:instanceId:DescribeInstance' :: DescribeInstance -> Text
instanceId} -> Text
instanceId) (\s :: DescribeInstance
s@DescribeInstance' {} Text
a -> DescribeInstance
s {$sel:instanceId:DescribeInstance' :: Text
instanceId = Text
a} :: DescribeInstance)

instance Core.AWSRequest DescribeInstance where
  type
    AWSResponse DescribeInstance =
      DescribeInstanceResponse
  request :: DescribeInstance -> Request DescribeInstance
request = Service -> DescribeInstance -> Request DescribeInstance
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeInstance)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeInstance))
-> Logger
-> Service
-> Proxy DescribeInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeInstance)))
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 Instance -> Int -> DescribeInstanceResponse
DescribeInstanceResponse'
            (Maybe Instance -> Int -> DescribeInstanceResponse)
-> Either String (Maybe Instance)
-> Either String (Int -> DescribeInstanceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Instance)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Instance")
            Either String (Int -> DescribeInstanceResponse)
-> Either String Int -> Either String DescribeInstanceResponse
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 DescribeInstance

instance Prelude.NFData DescribeInstance

instance Core.ToHeaders DescribeInstance where
  toHeaders :: DescribeInstance -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeInstance -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DescribeInstance where
  toPath :: DescribeInstance -> ByteString
toPath DescribeInstance' {Text
instanceId :: Text
$sel:instanceId:DescribeInstance' :: DescribeInstance -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/instance/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId]

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

-- | /See:/ 'newDescribeInstanceResponse' smart constructor.
data DescribeInstanceResponse = DescribeInstanceResponse'
  { -- | The name of the instance.
    DescribeInstanceResponse -> Maybe Instance
instance' :: Prelude.Maybe Instance,
    -- | The response's http status code.
    DescribeInstanceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeInstanceResponse -> DescribeInstanceResponse -> Bool
(DescribeInstanceResponse -> DescribeInstanceResponse -> Bool)
-> (DescribeInstanceResponse -> DescribeInstanceResponse -> Bool)
-> Eq DescribeInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInstanceResponse -> DescribeInstanceResponse -> Bool
$c/= :: DescribeInstanceResponse -> DescribeInstanceResponse -> Bool
== :: DescribeInstanceResponse -> DescribeInstanceResponse -> Bool
$c== :: DescribeInstanceResponse -> DescribeInstanceResponse -> Bool
Prelude.Eq, Int -> DescribeInstanceResponse -> ShowS
[DescribeInstanceResponse] -> ShowS
DescribeInstanceResponse -> String
(Int -> DescribeInstanceResponse -> ShowS)
-> (DescribeInstanceResponse -> String)
-> ([DescribeInstanceResponse] -> ShowS)
-> Show DescribeInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInstanceResponse] -> ShowS
$cshowList :: [DescribeInstanceResponse] -> ShowS
show :: DescribeInstanceResponse -> String
$cshow :: DescribeInstanceResponse -> String
showsPrec :: Int -> DescribeInstanceResponse -> ShowS
$cshowsPrec :: Int -> DescribeInstanceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeInstanceResponse -> Rep DescribeInstanceResponse x)
-> (forall x.
    Rep DescribeInstanceResponse x -> DescribeInstanceResponse)
-> Generic DescribeInstanceResponse
forall x.
Rep DescribeInstanceResponse x -> DescribeInstanceResponse
forall x.
DescribeInstanceResponse -> Rep DescribeInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeInstanceResponse x -> DescribeInstanceResponse
$cfrom :: forall x.
DescribeInstanceResponse -> Rep DescribeInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInstanceResponse' 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:
--
-- 'instance'', 'describeInstanceResponse_instance' - The name of the instance.
--
-- 'httpStatus', 'describeInstanceResponse_httpStatus' - The response's http status code.
newDescribeInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeInstanceResponse
newDescribeInstanceResponse :: Int -> DescribeInstanceResponse
newDescribeInstanceResponse Int
pHttpStatus_ =
  DescribeInstanceResponse' :: Maybe Instance -> Int -> DescribeInstanceResponse
DescribeInstanceResponse'
    { $sel:instance':DescribeInstanceResponse' :: Maybe Instance
instance' =
        Maybe Instance
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeInstanceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the instance.
describeInstanceResponse_instance :: Lens.Lens' DescribeInstanceResponse (Prelude.Maybe Instance)
describeInstanceResponse_instance :: (Maybe Instance -> f (Maybe Instance))
-> DescribeInstanceResponse -> f DescribeInstanceResponse
describeInstanceResponse_instance = (DescribeInstanceResponse -> Maybe Instance)
-> (DescribeInstanceResponse
    -> Maybe Instance -> DescribeInstanceResponse)
-> Lens
     DescribeInstanceResponse
     DescribeInstanceResponse
     (Maybe Instance)
     (Maybe Instance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstanceResponse' {Maybe Instance
instance' :: Maybe Instance
$sel:instance':DescribeInstanceResponse' :: DescribeInstanceResponse -> Maybe Instance
instance'} -> Maybe Instance
instance') (\s :: DescribeInstanceResponse
s@DescribeInstanceResponse' {} Maybe Instance
a -> DescribeInstanceResponse
s {$sel:instance':DescribeInstanceResponse' :: Maybe Instance
instance' = Maybe Instance
a} :: DescribeInstanceResponse)

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

instance Prelude.NFData DescribeInstanceResponse