{-# 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.CloudDirectory.GetFacet
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets details of the Facet, such as facet name, attributes, Rules, or
-- @ObjectType@. You can call this on all kinds of schema facets --
-- published, development, or applied.
module Amazonka.CloudDirectory.GetFacet
  ( -- * Creating a Request
    GetFacet (..),
    newGetFacet,

    -- * Request Lenses
    getFacet_schemaArn,
    getFacet_name,

    -- * Destructuring the Response
    GetFacetResponse (..),
    newGetFacetResponse,

    -- * Response Lenses
    getFacetResponse_facet,
    getFacetResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetFacet' smart constructor.
data GetFacet = GetFacet'
  { -- | The Amazon Resource Name (ARN) that is associated with the Facet. For
    -- more information, see arns.
    GetFacet -> Text
schemaArn :: Prelude.Text,
    -- | The name of the facet to retrieve.
    GetFacet -> Text
name :: Prelude.Text
  }
  deriving (GetFacet -> GetFacet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFacet -> GetFacet -> Bool
$c/= :: GetFacet -> GetFacet -> Bool
== :: GetFacet -> GetFacet -> Bool
$c== :: GetFacet -> GetFacet -> Bool
Prelude.Eq, ReadPrec [GetFacet]
ReadPrec GetFacet
Int -> ReadS GetFacet
ReadS [GetFacet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFacet]
$creadListPrec :: ReadPrec [GetFacet]
readPrec :: ReadPrec GetFacet
$creadPrec :: ReadPrec GetFacet
readList :: ReadS [GetFacet]
$creadList :: ReadS [GetFacet]
readsPrec :: Int -> ReadS GetFacet
$creadsPrec :: Int -> ReadS GetFacet
Prelude.Read, Int -> GetFacet -> ShowS
[GetFacet] -> ShowS
GetFacet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFacet] -> ShowS
$cshowList :: [GetFacet] -> ShowS
show :: GetFacet -> String
$cshow :: GetFacet -> String
showsPrec :: Int -> GetFacet -> ShowS
$cshowsPrec :: Int -> GetFacet -> ShowS
Prelude.Show, forall x. Rep GetFacet x -> GetFacet
forall x. GetFacet -> Rep GetFacet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFacet x -> GetFacet
$cfrom :: forall x. GetFacet -> Rep GetFacet x
Prelude.Generic)

-- |
-- Create a value of 'GetFacet' 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:
--
-- 'schemaArn', 'getFacet_schemaArn' - The Amazon Resource Name (ARN) that is associated with the Facet. For
-- more information, see arns.
--
-- 'name', 'getFacet_name' - The name of the facet to retrieve.
newGetFacet ::
  -- | 'schemaArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  GetFacet
newGetFacet :: Text -> Text -> GetFacet
newGetFacet Text
pSchemaArn_ Text
pName_ =
  GetFacet' {$sel:schemaArn:GetFacet' :: Text
schemaArn = Text
pSchemaArn_, $sel:name:GetFacet' :: Text
name = Text
pName_}

-- | The Amazon Resource Name (ARN) that is associated with the Facet. For
-- more information, see arns.
getFacet_schemaArn :: Lens.Lens' GetFacet Prelude.Text
getFacet_schemaArn :: Lens' GetFacet Text
getFacet_schemaArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFacet' {Text
schemaArn :: Text
$sel:schemaArn:GetFacet' :: GetFacet -> Text
schemaArn} -> Text
schemaArn) (\s :: GetFacet
s@GetFacet' {} Text
a -> GetFacet
s {$sel:schemaArn:GetFacet' :: Text
schemaArn = Text
a} :: GetFacet)

-- | The name of the facet to retrieve.
getFacet_name :: Lens.Lens' GetFacet Prelude.Text
getFacet_name :: Lens' GetFacet Text
getFacet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFacet' {Text
name :: Text
$sel:name:GetFacet' :: GetFacet -> Text
name} -> Text
name) (\s :: GetFacet
s@GetFacet' {} Text
a -> GetFacet
s {$sel:name:GetFacet' :: Text
name = Text
a} :: GetFacet)

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

instance Prelude.Hashable GetFacet where
  hashWithSalt :: Int -> GetFacet -> Int
hashWithSalt Int
_salt GetFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:GetFacet' :: GetFacet -> Text
$sel:schemaArn:GetFacet' :: GetFacet -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
schemaArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData GetFacet where
  rnf :: GetFacet -> ()
rnf GetFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:GetFacet' :: GetFacet -> Text
$sel:schemaArn:GetFacet' :: GetFacet -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
schemaArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders GetFacet where
  toHeaders :: GetFacet -> ResponseHeaders
toHeaders GetFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:GetFacet' :: GetFacet -> Text
$sel:schemaArn:GetFacet' :: GetFacet -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
schemaArn]

instance Data.ToJSON GetFacet where
  toJSON :: GetFacet -> Value
toJSON GetFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:GetFacet' :: GetFacet -> Text
$sel:schemaArn:GetFacet' :: GetFacet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

instance Data.ToPath GetFacet where
  toPath :: GetFacet -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/facet"

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

-- | /See:/ 'newGetFacetResponse' smart constructor.
data GetFacetResponse = GetFacetResponse'
  { -- | The Facet structure that is associated with the facet.
    GetFacetResponse -> Maybe Facet
facet :: Prelude.Maybe Facet,
    -- | The response's http status code.
    GetFacetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetFacetResponse -> GetFacetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFacetResponse -> GetFacetResponse -> Bool
$c/= :: GetFacetResponse -> GetFacetResponse -> Bool
== :: GetFacetResponse -> GetFacetResponse -> Bool
$c== :: GetFacetResponse -> GetFacetResponse -> Bool
Prelude.Eq, ReadPrec [GetFacetResponse]
ReadPrec GetFacetResponse
Int -> ReadS GetFacetResponse
ReadS [GetFacetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFacetResponse]
$creadListPrec :: ReadPrec [GetFacetResponse]
readPrec :: ReadPrec GetFacetResponse
$creadPrec :: ReadPrec GetFacetResponse
readList :: ReadS [GetFacetResponse]
$creadList :: ReadS [GetFacetResponse]
readsPrec :: Int -> ReadS GetFacetResponse
$creadsPrec :: Int -> ReadS GetFacetResponse
Prelude.Read, Int -> GetFacetResponse -> ShowS
[GetFacetResponse] -> ShowS
GetFacetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFacetResponse] -> ShowS
$cshowList :: [GetFacetResponse] -> ShowS
show :: GetFacetResponse -> String
$cshow :: GetFacetResponse -> String
showsPrec :: Int -> GetFacetResponse -> ShowS
$cshowsPrec :: Int -> GetFacetResponse -> ShowS
Prelude.Show, forall x. Rep GetFacetResponse x -> GetFacetResponse
forall x. GetFacetResponse -> Rep GetFacetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFacetResponse x -> GetFacetResponse
$cfrom :: forall x. GetFacetResponse -> Rep GetFacetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetFacetResponse' 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:
--
-- 'facet', 'getFacetResponse_facet' - The Facet structure that is associated with the facet.
--
-- 'httpStatus', 'getFacetResponse_httpStatus' - The response's http status code.
newGetFacetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetFacetResponse
newGetFacetResponse :: Int -> GetFacetResponse
newGetFacetResponse Int
pHttpStatus_ =
  GetFacetResponse'
    { $sel:facet:GetFacetResponse' :: Maybe Facet
facet = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetFacetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Facet structure that is associated with the facet.
getFacetResponse_facet :: Lens.Lens' GetFacetResponse (Prelude.Maybe Facet)
getFacetResponse_facet :: Lens' GetFacetResponse (Maybe Facet)
getFacetResponse_facet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFacetResponse' {Maybe Facet
facet :: Maybe Facet
$sel:facet:GetFacetResponse' :: GetFacetResponse -> Maybe Facet
facet} -> Maybe Facet
facet) (\s :: GetFacetResponse
s@GetFacetResponse' {} Maybe Facet
a -> GetFacetResponse
s {$sel:facet:GetFacetResponse' :: Maybe Facet
facet = Maybe Facet
a} :: GetFacetResponse)

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

instance Prelude.NFData GetFacetResponse where
  rnf :: GetFacetResponse -> ()
rnf GetFacetResponse' {Int
Maybe Facet
httpStatus :: Int
facet :: Maybe Facet
$sel:httpStatus:GetFacetResponse' :: GetFacetResponse -> Int
$sel:facet:GetFacetResponse' :: GetFacetResponse -> Maybe Facet
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Facet
facet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus