{-# 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.CreateTypedLinkFacet
-- 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 TypedLinkFacet. For more information, see
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_links.html#directory_objects_links_typedlink Typed Links>.
module Amazonka.CloudDirectory.CreateTypedLinkFacet
  ( -- * Creating a Request
    CreateTypedLinkFacet (..),
    newCreateTypedLinkFacet,

    -- * Request Lenses
    createTypedLinkFacet_schemaArn,
    createTypedLinkFacet_facet,

    -- * Destructuring the Response
    CreateTypedLinkFacetResponse (..),
    newCreateTypedLinkFacetResponse,

    -- * Response Lenses
    createTypedLinkFacetResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.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:/ 'newCreateTypedLinkFacet' smart constructor.
data CreateTypedLinkFacet = CreateTypedLinkFacet'
  { -- | The Amazon Resource Name (ARN) that is associated with the schema. For
    -- more information, see arns.
    CreateTypedLinkFacet -> Text
schemaArn :: Prelude.Text,
    -- | Facet structure that is associated with the typed link facet.
    CreateTypedLinkFacet -> TypedLinkFacet
facet :: TypedLinkFacet
  }
  deriving (CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool
(CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool)
-> (CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool)
-> Eq CreateTypedLinkFacet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool
$c/= :: CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool
== :: CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool
$c== :: CreateTypedLinkFacet -> CreateTypedLinkFacet -> Bool
Prelude.Eq, ReadPrec [CreateTypedLinkFacet]
ReadPrec CreateTypedLinkFacet
Int -> ReadS CreateTypedLinkFacet
ReadS [CreateTypedLinkFacet]
(Int -> ReadS CreateTypedLinkFacet)
-> ReadS [CreateTypedLinkFacet]
-> ReadPrec CreateTypedLinkFacet
-> ReadPrec [CreateTypedLinkFacet]
-> Read CreateTypedLinkFacet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTypedLinkFacet]
$creadListPrec :: ReadPrec [CreateTypedLinkFacet]
readPrec :: ReadPrec CreateTypedLinkFacet
$creadPrec :: ReadPrec CreateTypedLinkFacet
readList :: ReadS [CreateTypedLinkFacet]
$creadList :: ReadS [CreateTypedLinkFacet]
readsPrec :: Int -> ReadS CreateTypedLinkFacet
$creadsPrec :: Int -> ReadS CreateTypedLinkFacet
Prelude.Read, Int -> CreateTypedLinkFacet -> ShowS
[CreateTypedLinkFacet] -> ShowS
CreateTypedLinkFacet -> String
(Int -> CreateTypedLinkFacet -> ShowS)
-> (CreateTypedLinkFacet -> String)
-> ([CreateTypedLinkFacet] -> ShowS)
-> Show CreateTypedLinkFacet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTypedLinkFacet] -> ShowS
$cshowList :: [CreateTypedLinkFacet] -> ShowS
show :: CreateTypedLinkFacet -> String
$cshow :: CreateTypedLinkFacet -> String
showsPrec :: Int -> CreateTypedLinkFacet -> ShowS
$cshowsPrec :: Int -> CreateTypedLinkFacet -> ShowS
Prelude.Show, (forall x. CreateTypedLinkFacet -> Rep CreateTypedLinkFacet x)
-> (forall x. Rep CreateTypedLinkFacet x -> CreateTypedLinkFacet)
-> Generic CreateTypedLinkFacet
forall x. Rep CreateTypedLinkFacet x -> CreateTypedLinkFacet
forall x. CreateTypedLinkFacet -> Rep CreateTypedLinkFacet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTypedLinkFacet x -> CreateTypedLinkFacet
$cfrom :: forall x. CreateTypedLinkFacet -> Rep CreateTypedLinkFacet x
Prelude.Generic)

-- |
-- Create a value of 'CreateTypedLinkFacet' 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', 'createTypedLinkFacet_schemaArn' - The Amazon Resource Name (ARN) that is associated with the schema. For
-- more information, see arns.
--
-- 'facet', 'createTypedLinkFacet_facet' - Facet structure that is associated with the typed link facet.
newCreateTypedLinkFacet ::
  -- | 'schemaArn'
  Prelude.Text ->
  -- | 'facet'
  TypedLinkFacet ->
  CreateTypedLinkFacet
newCreateTypedLinkFacet :: Text -> TypedLinkFacet -> CreateTypedLinkFacet
newCreateTypedLinkFacet Text
pSchemaArn_ TypedLinkFacet
pFacet_ =
  CreateTypedLinkFacet' :: Text -> TypedLinkFacet -> CreateTypedLinkFacet
CreateTypedLinkFacet'
    { $sel:schemaArn:CreateTypedLinkFacet' :: Text
schemaArn = Text
pSchemaArn_,
      $sel:facet:CreateTypedLinkFacet' :: TypedLinkFacet
facet = TypedLinkFacet
pFacet_
    }

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

-- | Facet structure that is associated with the typed link facet.
createTypedLinkFacet_facet :: Lens.Lens' CreateTypedLinkFacet TypedLinkFacet
createTypedLinkFacet_facet :: (TypedLinkFacet -> f TypedLinkFacet)
-> CreateTypedLinkFacet -> f CreateTypedLinkFacet
createTypedLinkFacet_facet = (CreateTypedLinkFacet -> TypedLinkFacet)
-> (CreateTypedLinkFacet -> TypedLinkFacet -> CreateTypedLinkFacet)
-> Lens
     CreateTypedLinkFacet
     CreateTypedLinkFacet
     TypedLinkFacet
     TypedLinkFacet
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTypedLinkFacet' {TypedLinkFacet
facet :: TypedLinkFacet
$sel:facet:CreateTypedLinkFacet' :: CreateTypedLinkFacet -> TypedLinkFacet
facet} -> TypedLinkFacet
facet) (\s :: CreateTypedLinkFacet
s@CreateTypedLinkFacet' {} TypedLinkFacet
a -> CreateTypedLinkFacet
s {$sel:facet:CreateTypedLinkFacet' :: TypedLinkFacet
facet = TypedLinkFacet
a} :: CreateTypedLinkFacet)

instance Core.AWSRequest CreateTypedLinkFacet where
  type
    AWSResponse CreateTypedLinkFacet =
      CreateTypedLinkFacetResponse
  request :: CreateTypedLinkFacet -> Request CreateTypedLinkFacet
request = Service -> CreateTypedLinkFacet -> Request CreateTypedLinkFacet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTypedLinkFacet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTypedLinkFacet)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateTypedLinkFacet))
-> Logger
-> Service
-> Proxy CreateTypedLinkFacet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateTypedLinkFacet)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateTypedLinkFacetResponse
CreateTypedLinkFacetResponse'
            (Int -> CreateTypedLinkFacetResponse)
-> Either String Int -> Either String CreateTypedLinkFacetResponse
forall (f :: * -> *) a b. Functor 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 CreateTypedLinkFacet

instance Prelude.NFData CreateTypedLinkFacet

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

instance Core.ToJSON CreateTypedLinkFacet where
  toJSON :: CreateTypedLinkFacet -> Value
toJSON CreateTypedLinkFacet' {Text
TypedLinkFacet
facet :: TypedLinkFacet
schemaArn :: Text
$sel:facet:CreateTypedLinkFacet' :: CreateTypedLinkFacet -> TypedLinkFacet
$sel:schemaArn:CreateTypedLinkFacet' :: CreateTypedLinkFacet -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Facet" Text -> TypedLinkFacet -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TypedLinkFacet
facet)]
      )

instance Core.ToPath CreateTypedLinkFacet where
  toPath :: CreateTypedLinkFacet -> ByteString
toPath =
    ByteString -> CreateTypedLinkFacet -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/typedlink/facet/create"

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

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

-- |
-- Create a value of 'CreateTypedLinkFacetResponse' 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:
--
-- 'httpStatus', 'createTypedLinkFacetResponse_httpStatus' - The response's http status code.
newCreateTypedLinkFacetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateTypedLinkFacetResponse
newCreateTypedLinkFacetResponse :: Int -> CreateTypedLinkFacetResponse
newCreateTypedLinkFacetResponse Int
pHttpStatus_ =
  CreateTypedLinkFacetResponse' :: Int -> CreateTypedLinkFacetResponse
CreateTypedLinkFacetResponse'
    { $sel:httpStatus:CreateTypedLinkFacetResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData CreateTypedLinkFacetResponse