{-# 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.UpdateLinkAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a given typed link’s attributes. Attributes to be updated must
-- not contribute to the typed link’s identity, as defined by its
-- @IdentityAttributeOrder@.
module Amazonka.CloudDirectory.UpdateLinkAttributes
  ( -- * Creating a Request
    UpdateLinkAttributes (..),
    newUpdateLinkAttributes,

    -- * Request Lenses
    updateLinkAttributes_directoryArn,
    updateLinkAttributes_typedLinkSpecifier,
    updateLinkAttributes_attributeUpdates,

    -- * Destructuring the Response
    UpdateLinkAttributesResponse (..),
    newUpdateLinkAttributesResponse,

    -- * Response Lenses
    updateLinkAttributesResponse_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:/ 'newUpdateLinkAttributes' smart constructor.
data UpdateLinkAttributes = UpdateLinkAttributes'
  { -- | The Amazon Resource Name (ARN) that is associated with the Directory
    -- where the updated typed link resides. For more information, see arns or
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_links.html#directory_objects_links_typedlink Typed Links>.
    UpdateLinkAttributes -> Text
directoryArn :: Prelude.Text,
    -- | Allows a typed link specifier to be accepted as input.
    UpdateLinkAttributes -> TypedLinkSpecifier
typedLinkSpecifier :: TypedLinkSpecifier,
    -- | The attributes update structure.
    UpdateLinkAttributes -> [LinkAttributeUpdate]
attributeUpdates :: [LinkAttributeUpdate]
  }
  deriving (UpdateLinkAttributes -> UpdateLinkAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLinkAttributes -> UpdateLinkAttributes -> Bool
$c/= :: UpdateLinkAttributes -> UpdateLinkAttributes -> Bool
== :: UpdateLinkAttributes -> UpdateLinkAttributes -> Bool
$c== :: UpdateLinkAttributes -> UpdateLinkAttributes -> Bool
Prelude.Eq, ReadPrec [UpdateLinkAttributes]
ReadPrec UpdateLinkAttributes
Int -> ReadS UpdateLinkAttributes
ReadS [UpdateLinkAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLinkAttributes]
$creadListPrec :: ReadPrec [UpdateLinkAttributes]
readPrec :: ReadPrec UpdateLinkAttributes
$creadPrec :: ReadPrec UpdateLinkAttributes
readList :: ReadS [UpdateLinkAttributes]
$creadList :: ReadS [UpdateLinkAttributes]
readsPrec :: Int -> ReadS UpdateLinkAttributes
$creadsPrec :: Int -> ReadS UpdateLinkAttributes
Prelude.Read, Int -> UpdateLinkAttributes -> ShowS
[UpdateLinkAttributes] -> ShowS
UpdateLinkAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLinkAttributes] -> ShowS
$cshowList :: [UpdateLinkAttributes] -> ShowS
show :: UpdateLinkAttributes -> String
$cshow :: UpdateLinkAttributes -> String
showsPrec :: Int -> UpdateLinkAttributes -> ShowS
$cshowsPrec :: Int -> UpdateLinkAttributes -> ShowS
Prelude.Show, forall x. Rep UpdateLinkAttributes x -> UpdateLinkAttributes
forall x. UpdateLinkAttributes -> Rep UpdateLinkAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLinkAttributes x -> UpdateLinkAttributes
$cfrom :: forall x. UpdateLinkAttributes -> Rep UpdateLinkAttributes x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLinkAttributes' 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:
--
-- 'directoryArn', 'updateLinkAttributes_directoryArn' - The Amazon Resource Name (ARN) that is associated with the Directory
-- where the updated typed link resides. For more information, see arns or
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_links.html#directory_objects_links_typedlink Typed Links>.
--
-- 'typedLinkSpecifier', 'updateLinkAttributes_typedLinkSpecifier' - Allows a typed link specifier to be accepted as input.
--
-- 'attributeUpdates', 'updateLinkAttributes_attributeUpdates' - The attributes update structure.
newUpdateLinkAttributes ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'typedLinkSpecifier'
  TypedLinkSpecifier ->
  UpdateLinkAttributes
newUpdateLinkAttributes :: Text -> TypedLinkSpecifier -> UpdateLinkAttributes
newUpdateLinkAttributes
  Text
pDirectoryArn_
  TypedLinkSpecifier
pTypedLinkSpecifier_ =
    UpdateLinkAttributes'
      { $sel:directoryArn:UpdateLinkAttributes' :: Text
directoryArn =
          Text
pDirectoryArn_,
        $sel:typedLinkSpecifier:UpdateLinkAttributes' :: TypedLinkSpecifier
typedLinkSpecifier = TypedLinkSpecifier
pTypedLinkSpecifier_,
        $sel:attributeUpdates:UpdateLinkAttributes' :: [LinkAttributeUpdate]
attributeUpdates = forall a. Monoid a => a
Prelude.mempty
      }

-- | The Amazon Resource Name (ARN) that is associated with the Directory
-- where the updated typed link resides. For more information, see arns or
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_links.html#directory_objects_links_typedlink Typed Links>.
updateLinkAttributes_directoryArn :: Lens.Lens' UpdateLinkAttributes Prelude.Text
updateLinkAttributes_directoryArn :: Lens' UpdateLinkAttributes Text
updateLinkAttributes_directoryArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLinkAttributes' {Text
directoryArn :: Text
$sel:directoryArn:UpdateLinkAttributes' :: UpdateLinkAttributes -> Text
directoryArn} -> Text
directoryArn) (\s :: UpdateLinkAttributes
s@UpdateLinkAttributes' {} Text
a -> UpdateLinkAttributes
s {$sel:directoryArn:UpdateLinkAttributes' :: Text
directoryArn = Text
a} :: UpdateLinkAttributes)

-- | Allows a typed link specifier to be accepted as input.
updateLinkAttributes_typedLinkSpecifier :: Lens.Lens' UpdateLinkAttributes TypedLinkSpecifier
updateLinkAttributes_typedLinkSpecifier :: Lens' UpdateLinkAttributes TypedLinkSpecifier
updateLinkAttributes_typedLinkSpecifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLinkAttributes' {TypedLinkSpecifier
typedLinkSpecifier :: TypedLinkSpecifier
$sel:typedLinkSpecifier:UpdateLinkAttributes' :: UpdateLinkAttributes -> TypedLinkSpecifier
typedLinkSpecifier} -> TypedLinkSpecifier
typedLinkSpecifier) (\s :: UpdateLinkAttributes
s@UpdateLinkAttributes' {} TypedLinkSpecifier
a -> UpdateLinkAttributes
s {$sel:typedLinkSpecifier:UpdateLinkAttributes' :: TypedLinkSpecifier
typedLinkSpecifier = TypedLinkSpecifier
a} :: UpdateLinkAttributes)

-- | The attributes update structure.
updateLinkAttributes_attributeUpdates :: Lens.Lens' UpdateLinkAttributes [LinkAttributeUpdate]
updateLinkAttributes_attributeUpdates :: Lens' UpdateLinkAttributes [LinkAttributeUpdate]
updateLinkAttributes_attributeUpdates = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLinkAttributes' {[LinkAttributeUpdate]
attributeUpdates :: [LinkAttributeUpdate]
$sel:attributeUpdates:UpdateLinkAttributes' :: UpdateLinkAttributes -> [LinkAttributeUpdate]
attributeUpdates} -> [LinkAttributeUpdate]
attributeUpdates) (\s :: UpdateLinkAttributes
s@UpdateLinkAttributes' {} [LinkAttributeUpdate]
a -> UpdateLinkAttributes
s {$sel:attributeUpdates:UpdateLinkAttributes' :: [LinkAttributeUpdate]
attributeUpdates = [LinkAttributeUpdate]
a} :: UpdateLinkAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateLinkAttributes where
  type
    AWSResponse UpdateLinkAttributes =
      UpdateLinkAttributesResponse
  request :: (Service -> Service)
-> UpdateLinkAttributes -> Request UpdateLinkAttributes
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 UpdateLinkAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLinkAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateLinkAttributesResponse
UpdateLinkAttributesResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateLinkAttributes where
  hashWithSalt :: Int -> UpdateLinkAttributes -> Int
hashWithSalt Int
_salt UpdateLinkAttributes' {[LinkAttributeUpdate]
Text
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
directoryArn :: Text
$sel:attributeUpdates:UpdateLinkAttributes' :: UpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:UpdateLinkAttributes' :: UpdateLinkAttributes -> TypedLinkSpecifier
$sel:directoryArn:UpdateLinkAttributes' :: UpdateLinkAttributes -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directoryArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TypedLinkSpecifier
typedLinkSpecifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [LinkAttributeUpdate]
attributeUpdates

instance Prelude.NFData UpdateLinkAttributes where
  rnf :: UpdateLinkAttributes -> ()
rnf UpdateLinkAttributes' {[LinkAttributeUpdate]
Text
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
directoryArn :: Text
$sel:attributeUpdates:UpdateLinkAttributes' :: UpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:UpdateLinkAttributes' :: UpdateLinkAttributes -> TypedLinkSpecifier
$sel:directoryArn:UpdateLinkAttributes' :: UpdateLinkAttributes -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
directoryArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TypedLinkSpecifier
typedLinkSpecifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [LinkAttributeUpdate]
attributeUpdates

instance Data.ToHeaders UpdateLinkAttributes where
  toHeaders :: UpdateLinkAttributes -> ResponseHeaders
toHeaders UpdateLinkAttributes' {[LinkAttributeUpdate]
Text
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
directoryArn :: Text
$sel:attributeUpdates:UpdateLinkAttributes' :: UpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:UpdateLinkAttributes' :: UpdateLinkAttributes -> TypedLinkSpecifier
$sel:directoryArn:UpdateLinkAttributes' :: UpdateLinkAttributes -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
directoryArn]

instance Data.ToJSON UpdateLinkAttributes where
  toJSON :: UpdateLinkAttributes -> Value
toJSON UpdateLinkAttributes' {[LinkAttributeUpdate]
Text
TypedLinkSpecifier
attributeUpdates :: [LinkAttributeUpdate]
typedLinkSpecifier :: TypedLinkSpecifier
directoryArn :: Text
$sel:attributeUpdates:UpdateLinkAttributes' :: UpdateLinkAttributes -> [LinkAttributeUpdate]
$sel:typedLinkSpecifier:UpdateLinkAttributes' :: UpdateLinkAttributes -> TypedLinkSpecifier
$sel:directoryArn:UpdateLinkAttributes' :: UpdateLinkAttributes -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TypedLinkSpecifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TypedLinkSpecifier
typedLinkSpecifier),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AttributeUpdates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [LinkAttributeUpdate]
attributeUpdates)
          ]
      )

instance Data.ToPath UpdateLinkAttributes where
  toPath :: UpdateLinkAttributes -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/typedlink/attributes/update"

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

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

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

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

instance Prelude.NFData UpdateLinkAttributesResponse where
  rnf :: UpdateLinkAttributesResponse -> ()
rnf UpdateLinkAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateLinkAttributesResponse' :: UpdateLinkAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus