{-# 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 #-}
module Amazonka.NetworkManager.AssociateLink
(
AssociateLink (..),
newAssociateLink,
associateLink_globalNetworkId,
associateLink_deviceId,
associateLink_linkId,
AssociateLinkResponse (..),
newAssociateLinkResponse,
associateLinkResponse_linkAssociation,
associateLinkResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data AssociateLink = AssociateLink'
{
AssociateLink -> Text
globalNetworkId :: Prelude.Text,
AssociateLink -> Text
deviceId :: Prelude.Text,
AssociateLink -> Text
linkId :: Prelude.Text
}
deriving (AssociateLink -> AssociateLink -> Bool
(AssociateLink -> AssociateLink -> Bool)
-> (AssociateLink -> AssociateLink -> Bool) -> Eq AssociateLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateLink -> AssociateLink -> Bool
$c/= :: AssociateLink -> AssociateLink -> Bool
== :: AssociateLink -> AssociateLink -> Bool
$c== :: AssociateLink -> AssociateLink -> Bool
Prelude.Eq, ReadPrec [AssociateLink]
ReadPrec AssociateLink
Int -> ReadS AssociateLink
ReadS [AssociateLink]
(Int -> ReadS AssociateLink)
-> ReadS [AssociateLink]
-> ReadPrec AssociateLink
-> ReadPrec [AssociateLink]
-> Read AssociateLink
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateLink]
$creadListPrec :: ReadPrec [AssociateLink]
readPrec :: ReadPrec AssociateLink
$creadPrec :: ReadPrec AssociateLink
readList :: ReadS [AssociateLink]
$creadList :: ReadS [AssociateLink]
readsPrec :: Int -> ReadS AssociateLink
$creadsPrec :: Int -> ReadS AssociateLink
Prelude.Read, Int -> AssociateLink -> ShowS
[AssociateLink] -> ShowS
AssociateLink -> String
(Int -> AssociateLink -> ShowS)
-> (AssociateLink -> String)
-> ([AssociateLink] -> ShowS)
-> Show AssociateLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateLink] -> ShowS
$cshowList :: [AssociateLink] -> ShowS
show :: AssociateLink -> String
$cshow :: AssociateLink -> String
showsPrec :: Int -> AssociateLink -> ShowS
$cshowsPrec :: Int -> AssociateLink -> ShowS
Prelude.Show, (forall x. AssociateLink -> Rep AssociateLink x)
-> (forall x. Rep AssociateLink x -> AssociateLink)
-> Generic AssociateLink
forall x. Rep AssociateLink x -> AssociateLink
forall x. AssociateLink -> Rep AssociateLink x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateLink x -> AssociateLink
$cfrom :: forall x. AssociateLink -> Rep AssociateLink x
Prelude.Generic)
newAssociateLink ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
AssociateLink
newAssociateLink :: Text -> Text -> Text -> AssociateLink
newAssociateLink
Text
pGlobalNetworkId_
Text
pDeviceId_
Text
pLinkId_ =
AssociateLink' :: Text -> Text -> Text -> AssociateLink
AssociateLink'
{ $sel:globalNetworkId:AssociateLink' :: Text
globalNetworkId = Text
pGlobalNetworkId_,
$sel:deviceId:AssociateLink' :: Text
deviceId = Text
pDeviceId_,
$sel:linkId:AssociateLink' :: Text
linkId = Text
pLinkId_
}
associateLink_globalNetworkId :: Lens.Lens' AssociateLink Prelude.Text
associateLink_globalNetworkId :: (Text -> f Text) -> AssociateLink -> f AssociateLink
associateLink_globalNetworkId = (AssociateLink -> Text)
-> (AssociateLink -> Text -> AssociateLink)
-> Lens AssociateLink AssociateLink Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLink' {Text
globalNetworkId :: Text
$sel:globalNetworkId:AssociateLink' :: AssociateLink -> Text
globalNetworkId} -> Text
globalNetworkId) (\s :: AssociateLink
s@AssociateLink' {} Text
a -> AssociateLink
s {$sel:globalNetworkId:AssociateLink' :: Text
globalNetworkId = Text
a} :: AssociateLink)
associateLink_deviceId :: Lens.Lens' AssociateLink Prelude.Text
associateLink_deviceId :: (Text -> f Text) -> AssociateLink -> f AssociateLink
associateLink_deviceId = (AssociateLink -> Text)
-> (AssociateLink -> Text -> AssociateLink)
-> Lens AssociateLink AssociateLink Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLink' {Text
deviceId :: Text
$sel:deviceId:AssociateLink' :: AssociateLink -> Text
deviceId} -> Text
deviceId) (\s :: AssociateLink
s@AssociateLink' {} Text
a -> AssociateLink
s {$sel:deviceId:AssociateLink' :: Text
deviceId = Text
a} :: AssociateLink)
associateLink_linkId :: Lens.Lens' AssociateLink Prelude.Text
associateLink_linkId :: (Text -> f Text) -> AssociateLink -> f AssociateLink
associateLink_linkId = (AssociateLink -> Text)
-> (AssociateLink -> Text -> AssociateLink)
-> Lens AssociateLink AssociateLink Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLink' {Text
linkId :: Text
$sel:linkId:AssociateLink' :: AssociateLink -> Text
linkId} -> Text
linkId) (\s :: AssociateLink
s@AssociateLink' {} Text
a -> AssociateLink
s {$sel:linkId:AssociateLink' :: Text
linkId = Text
a} :: AssociateLink)
instance Core.AWSRequest AssociateLink where
type
AWSResponse AssociateLink =
AssociateLinkResponse
request :: AssociateLink -> Request AssociateLink
request = Service -> AssociateLink -> Request AssociateLink
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AssociateLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateLink)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AssociateLink))
-> Logger
-> Service
-> Proxy AssociateLink
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociateLink)))
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 LinkAssociation -> Int -> AssociateLinkResponse
AssociateLinkResponse'
(Maybe LinkAssociation -> Int -> AssociateLinkResponse)
-> Either String (Maybe LinkAssociation)
-> Either String (Int -> AssociateLinkResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe LinkAssociation)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LinkAssociation")
Either String (Int -> AssociateLinkResponse)
-> Either String Int -> Either String AssociateLinkResponse
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 AssociateLink
instance Prelude.NFData AssociateLink
instance Core.ToHeaders AssociateLink where
toHeaders :: AssociateLink -> ResponseHeaders
toHeaders =
ResponseHeaders -> AssociateLink -> 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.ToJSON AssociateLink where
toJSON :: AssociateLink -> Value
toJSON AssociateLink' {Text
linkId :: Text
deviceId :: Text
globalNetworkId :: Text
$sel:linkId:AssociateLink' :: AssociateLink -> Text
$sel:deviceId:AssociateLink' :: AssociateLink -> Text
$sel:globalNetworkId:AssociateLink' :: AssociateLink -> 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
"DeviceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deviceId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LinkId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
linkId)
]
)
instance Core.ToPath AssociateLink where
toPath :: AssociateLink -> ByteString
toPath AssociateLink' {Text
linkId :: Text
deviceId :: Text
globalNetworkId :: Text
$sel:linkId:AssociateLink' :: AssociateLink -> Text
$sel:deviceId:AssociateLink' :: AssociateLink -> Text
$sel:globalNetworkId:AssociateLink' :: AssociateLink -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/global-networks/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
globalNetworkId,
ByteString
"/link-associations"
]
instance Core.ToQuery AssociateLink where
toQuery :: AssociateLink -> QueryString
toQuery = QueryString -> AssociateLink -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AssociateLinkResponse = AssociateLinkResponse'
{
AssociateLinkResponse -> Maybe LinkAssociation
linkAssociation :: Prelude.Maybe LinkAssociation,
AssociateLinkResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AssociateLinkResponse -> AssociateLinkResponse -> Bool
(AssociateLinkResponse -> AssociateLinkResponse -> Bool)
-> (AssociateLinkResponse -> AssociateLinkResponse -> Bool)
-> Eq AssociateLinkResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateLinkResponse -> AssociateLinkResponse -> Bool
$c/= :: AssociateLinkResponse -> AssociateLinkResponse -> Bool
== :: AssociateLinkResponse -> AssociateLinkResponse -> Bool
$c== :: AssociateLinkResponse -> AssociateLinkResponse -> Bool
Prelude.Eq, ReadPrec [AssociateLinkResponse]
ReadPrec AssociateLinkResponse
Int -> ReadS AssociateLinkResponse
ReadS [AssociateLinkResponse]
(Int -> ReadS AssociateLinkResponse)
-> ReadS [AssociateLinkResponse]
-> ReadPrec AssociateLinkResponse
-> ReadPrec [AssociateLinkResponse]
-> Read AssociateLinkResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateLinkResponse]
$creadListPrec :: ReadPrec [AssociateLinkResponse]
readPrec :: ReadPrec AssociateLinkResponse
$creadPrec :: ReadPrec AssociateLinkResponse
readList :: ReadS [AssociateLinkResponse]
$creadList :: ReadS [AssociateLinkResponse]
readsPrec :: Int -> ReadS AssociateLinkResponse
$creadsPrec :: Int -> ReadS AssociateLinkResponse
Prelude.Read, Int -> AssociateLinkResponse -> ShowS
[AssociateLinkResponse] -> ShowS
AssociateLinkResponse -> String
(Int -> AssociateLinkResponse -> ShowS)
-> (AssociateLinkResponse -> String)
-> ([AssociateLinkResponse] -> ShowS)
-> Show AssociateLinkResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateLinkResponse] -> ShowS
$cshowList :: [AssociateLinkResponse] -> ShowS
show :: AssociateLinkResponse -> String
$cshow :: AssociateLinkResponse -> String
showsPrec :: Int -> AssociateLinkResponse -> ShowS
$cshowsPrec :: Int -> AssociateLinkResponse -> ShowS
Prelude.Show, (forall x. AssociateLinkResponse -> Rep AssociateLinkResponse x)
-> (forall x. Rep AssociateLinkResponse x -> AssociateLinkResponse)
-> Generic AssociateLinkResponse
forall x. Rep AssociateLinkResponse x -> AssociateLinkResponse
forall x. AssociateLinkResponse -> Rep AssociateLinkResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateLinkResponse x -> AssociateLinkResponse
$cfrom :: forall x. AssociateLinkResponse -> Rep AssociateLinkResponse x
Prelude.Generic)
newAssociateLinkResponse ::
Prelude.Int ->
AssociateLinkResponse
newAssociateLinkResponse :: Int -> AssociateLinkResponse
newAssociateLinkResponse Int
pHttpStatus_ =
AssociateLinkResponse' :: Maybe LinkAssociation -> Int -> AssociateLinkResponse
AssociateLinkResponse'
{ $sel:linkAssociation:AssociateLinkResponse' :: Maybe LinkAssociation
linkAssociation =
Maybe LinkAssociation
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AssociateLinkResponse' :: Int
httpStatus = Int
pHttpStatus_
}
associateLinkResponse_linkAssociation :: Lens.Lens' AssociateLinkResponse (Prelude.Maybe LinkAssociation)
associateLinkResponse_linkAssociation :: (Maybe LinkAssociation -> f (Maybe LinkAssociation))
-> AssociateLinkResponse -> f AssociateLinkResponse
associateLinkResponse_linkAssociation = (AssociateLinkResponse -> Maybe LinkAssociation)
-> (AssociateLinkResponse
-> Maybe LinkAssociation -> AssociateLinkResponse)
-> Lens
AssociateLinkResponse
AssociateLinkResponse
(Maybe LinkAssociation)
(Maybe LinkAssociation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLinkResponse' {Maybe LinkAssociation
linkAssociation :: Maybe LinkAssociation
$sel:linkAssociation:AssociateLinkResponse' :: AssociateLinkResponse -> Maybe LinkAssociation
linkAssociation} -> Maybe LinkAssociation
linkAssociation) (\s :: AssociateLinkResponse
s@AssociateLinkResponse' {} Maybe LinkAssociation
a -> AssociateLinkResponse
s {$sel:linkAssociation:AssociateLinkResponse' :: Maybe LinkAssociation
linkAssociation = Maybe LinkAssociation
a} :: AssociateLinkResponse)
associateLinkResponse_httpStatus :: Lens.Lens' AssociateLinkResponse Prelude.Int
associateLinkResponse_httpStatus :: (Int -> f Int) -> AssociateLinkResponse -> f AssociateLinkResponse
associateLinkResponse_httpStatus = (AssociateLinkResponse -> Int)
-> (AssociateLinkResponse -> Int -> AssociateLinkResponse)
-> Lens AssociateLinkResponse AssociateLinkResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateLinkResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateLinkResponse' :: AssociateLinkResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AssociateLinkResponse
s@AssociateLinkResponse' {} Int
a -> AssociateLinkResponse
s {$sel:httpStatus:AssociateLinkResponse' :: Int
httpStatus = Int
a} :: AssociateLinkResponse)
instance Prelude.NFData AssociateLinkResponse