{-# 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.AlexaBusiness.GetProfile
-- 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)
--
-- Gets the details of a room profile by profile ARN.
module Amazonka.AlexaBusiness.GetProfile
  ( -- * Creating a Request
    GetProfile (..),
    newGetProfile,

    -- * Request Lenses
    getProfile_profileArn,

    -- * Destructuring the Response
    GetProfileResponse (..),
    newGetProfileResponse,

    -- * Response Lenses
    getProfileResponse_profile,
    getProfileResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.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:/ 'newGetProfile' smart constructor.
data GetProfile = GetProfile'
  { -- | The ARN of the room profile for which to request details. Required.
    GetProfile -> Maybe Text
profileArn :: Prelude.Maybe Prelude.Text
  }
  deriving (GetProfile -> GetProfile -> Bool
(GetProfile -> GetProfile -> Bool)
-> (GetProfile -> GetProfile -> Bool) -> Eq GetProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetProfile -> GetProfile -> Bool
$c/= :: GetProfile -> GetProfile -> Bool
== :: GetProfile -> GetProfile -> Bool
$c== :: GetProfile -> GetProfile -> Bool
Prelude.Eq, ReadPrec [GetProfile]
ReadPrec GetProfile
Int -> ReadS GetProfile
ReadS [GetProfile]
(Int -> ReadS GetProfile)
-> ReadS [GetProfile]
-> ReadPrec GetProfile
-> ReadPrec [GetProfile]
-> Read GetProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetProfile]
$creadListPrec :: ReadPrec [GetProfile]
readPrec :: ReadPrec GetProfile
$creadPrec :: ReadPrec GetProfile
readList :: ReadS [GetProfile]
$creadList :: ReadS [GetProfile]
readsPrec :: Int -> ReadS GetProfile
$creadsPrec :: Int -> ReadS GetProfile
Prelude.Read, Int -> GetProfile -> ShowS
[GetProfile] -> ShowS
GetProfile -> String
(Int -> GetProfile -> ShowS)
-> (GetProfile -> String)
-> ([GetProfile] -> ShowS)
-> Show GetProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetProfile] -> ShowS
$cshowList :: [GetProfile] -> ShowS
show :: GetProfile -> String
$cshow :: GetProfile -> String
showsPrec :: Int -> GetProfile -> ShowS
$cshowsPrec :: Int -> GetProfile -> ShowS
Prelude.Show, (forall x. GetProfile -> Rep GetProfile x)
-> (forall x. Rep GetProfile x -> GetProfile) -> Generic GetProfile
forall x. Rep GetProfile x -> GetProfile
forall x. GetProfile -> Rep GetProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetProfile x -> GetProfile
$cfrom :: forall x. GetProfile -> Rep GetProfile x
Prelude.Generic)

-- |
-- Create a value of 'GetProfile' 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:
--
-- 'profileArn', 'getProfile_profileArn' - The ARN of the room profile for which to request details. Required.
newGetProfile ::
  GetProfile
newGetProfile :: GetProfile
newGetProfile =
  GetProfile' :: Maybe Text -> GetProfile
GetProfile' {$sel:profileArn:GetProfile' :: Maybe Text
profileArn = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ARN of the room profile for which to request details. Required.
getProfile_profileArn :: Lens.Lens' GetProfile (Prelude.Maybe Prelude.Text)
getProfile_profileArn :: (Maybe Text -> f (Maybe Text)) -> GetProfile -> f GetProfile
getProfile_profileArn = (GetProfile -> Maybe Text)
-> (GetProfile -> Maybe Text -> GetProfile)
-> Lens GetProfile GetProfile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProfile' {Maybe Text
profileArn :: Maybe Text
$sel:profileArn:GetProfile' :: GetProfile -> Maybe Text
profileArn} -> Maybe Text
profileArn) (\s :: GetProfile
s@GetProfile' {} Maybe Text
a -> GetProfile
s {$sel:profileArn:GetProfile' :: Maybe Text
profileArn = Maybe Text
a} :: GetProfile)

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

instance Prelude.NFData GetProfile

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

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

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

-- | /See:/ 'newGetProfileResponse' smart constructor.
data GetProfileResponse = GetProfileResponse'
  { -- | The details of the room profile requested. Required.
    GetProfileResponse -> Maybe Profile
profile :: Prelude.Maybe Profile,
    -- | The response's http status code.
    GetProfileResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetProfileResponse -> GetProfileResponse -> Bool
(GetProfileResponse -> GetProfileResponse -> Bool)
-> (GetProfileResponse -> GetProfileResponse -> Bool)
-> Eq GetProfileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetProfileResponse -> GetProfileResponse -> Bool
$c/= :: GetProfileResponse -> GetProfileResponse -> Bool
== :: GetProfileResponse -> GetProfileResponse -> Bool
$c== :: GetProfileResponse -> GetProfileResponse -> Bool
Prelude.Eq, ReadPrec [GetProfileResponse]
ReadPrec GetProfileResponse
Int -> ReadS GetProfileResponse
ReadS [GetProfileResponse]
(Int -> ReadS GetProfileResponse)
-> ReadS [GetProfileResponse]
-> ReadPrec GetProfileResponse
-> ReadPrec [GetProfileResponse]
-> Read GetProfileResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetProfileResponse]
$creadListPrec :: ReadPrec [GetProfileResponse]
readPrec :: ReadPrec GetProfileResponse
$creadPrec :: ReadPrec GetProfileResponse
readList :: ReadS [GetProfileResponse]
$creadList :: ReadS [GetProfileResponse]
readsPrec :: Int -> ReadS GetProfileResponse
$creadsPrec :: Int -> ReadS GetProfileResponse
Prelude.Read, Int -> GetProfileResponse -> ShowS
[GetProfileResponse] -> ShowS
GetProfileResponse -> String
(Int -> GetProfileResponse -> ShowS)
-> (GetProfileResponse -> String)
-> ([GetProfileResponse] -> ShowS)
-> Show GetProfileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetProfileResponse] -> ShowS
$cshowList :: [GetProfileResponse] -> ShowS
show :: GetProfileResponse -> String
$cshow :: GetProfileResponse -> String
showsPrec :: Int -> GetProfileResponse -> ShowS
$cshowsPrec :: Int -> GetProfileResponse -> ShowS
Prelude.Show, (forall x. GetProfileResponse -> Rep GetProfileResponse x)
-> (forall x. Rep GetProfileResponse x -> GetProfileResponse)
-> Generic GetProfileResponse
forall x. Rep GetProfileResponse x -> GetProfileResponse
forall x. GetProfileResponse -> Rep GetProfileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetProfileResponse x -> GetProfileResponse
$cfrom :: forall x. GetProfileResponse -> Rep GetProfileResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetProfileResponse' 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:
--
-- 'profile', 'getProfileResponse_profile' - The details of the room profile requested. Required.
--
-- 'httpStatus', 'getProfileResponse_httpStatus' - The response's http status code.
newGetProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetProfileResponse
newGetProfileResponse :: Int -> GetProfileResponse
newGetProfileResponse Int
pHttpStatus_ =
  GetProfileResponse' :: Maybe Profile -> Int -> GetProfileResponse
GetProfileResponse'
    { $sel:profile:GetProfileResponse' :: Maybe Profile
profile = Maybe Profile
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the room profile requested. Required.
getProfileResponse_profile :: Lens.Lens' GetProfileResponse (Prelude.Maybe Profile)
getProfileResponse_profile :: (Maybe Profile -> f (Maybe Profile))
-> GetProfileResponse -> f GetProfileResponse
getProfileResponse_profile = (GetProfileResponse -> Maybe Profile)
-> (GetProfileResponse -> Maybe Profile -> GetProfileResponse)
-> Lens
     GetProfileResponse
     GetProfileResponse
     (Maybe Profile)
     (Maybe Profile)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetProfileResponse' {Maybe Profile
profile :: Maybe Profile
$sel:profile:GetProfileResponse' :: GetProfileResponse -> Maybe Profile
profile} -> Maybe Profile
profile) (\s :: GetProfileResponse
s@GetProfileResponse' {} Maybe Profile
a -> GetProfileResponse
s {$sel:profile:GetProfileResponse' :: Maybe Profile
profile = Maybe Profile
a} :: GetProfileResponse)

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

instance Prelude.NFData GetProfileResponse