{-# 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.ELBV2.SetIpAddressType
-- 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)
--
-- Sets the type of IP addresses used by the subnets of the specified
-- Application Load Balancer or Network Load Balancer.
module Amazonka.ELBV2.SetIpAddressType
  ( -- * Creating a Request
    SetIpAddressType (..),
    newSetIpAddressType,

    -- * Request Lenses
    setIpAddressType_loadBalancerArn,
    setIpAddressType_ipAddressType,

    -- * Destructuring the Response
    SetIpAddressTypeResponse (..),
    newSetIpAddressTypeResponse,

    -- * Response Lenses
    setIpAddressTypeResponse_ipAddressType,
    setIpAddressTypeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types
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:/ 'newSetIpAddressType' smart constructor.
data SetIpAddressType = SetIpAddressType'
  { -- | The Amazon Resource Name (ARN) of the load balancer.
    SetIpAddressType -> Text
loadBalancerArn :: Prelude.Text,
    -- | The IP address type. The possible values are @ipv4@ (for IPv4 addresses)
    -- and @dualstack@ (for IPv4 and IPv6 addresses). Internal load balancers
    -- must use @ipv4@. You can’t specify @dualstack@ for a load balancer with
    -- a UDP or TCP_UDP listener.
    SetIpAddressType -> IpAddressType
ipAddressType :: IpAddressType
  }
  deriving (SetIpAddressType -> SetIpAddressType -> Bool
(SetIpAddressType -> SetIpAddressType -> Bool)
-> (SetIpAddressType -> SetIpAddressType -> Bool)
-> Eq SetIpAddressType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetIpAddressType -> SetIpAddressType -> Bool
$c/= :: SetIpAddressType -> SetIpAddressType -> Bool
== :: SetIpAddressType -> SetIpAddressType -> Bool
$c== :: SetIpAddressType -> SetIpAddressType -> Bool
Prelude.Eq, ReadPrec [SetIpAddressType]
ReadPrec SetIpAddressType
Int -> ReadS SetIpAddressType
ReadS [SetIpAddressType]
(Int -> ReadS SetIpAddressType)
-> ReadS [SetIpAddressType]
-> ReadPrec SetIpAddressType
-> ReadPrec [SetIpAddressType]
-> Read SetIpAddressType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetIpAddressType]
$creadListPrec :: ReadPrec [SetIpAddressType]
readPrec :: ReadPrec SetIpAddressType
$creadPrec :: ReadPrec SetIpAddressType
readList :: ReadS [SetIpAddressType]
$creadList :: ReadS [SetIpAddressType]
readsPrec :: Int -> ReadS SetIpAddressType
$creadsPrec :: Int -> ReadS SetIpAddressType
Prelude.Read, Int -> SetIpAddressType -> ShowS
[SetIpAddressType] -> ShowS
SetIpAddressType -> String
(Int -> SetIpAddressType -> ShowS)
-> (SetIpAddressType -> String)
-> ([SetIpAddressType] -> ShowS)
-> Show SetIpAddressType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetIpAddressType] -> ShowS
$cshowList :: [SetIpAddressType] -> ShowS
show :: SetIpAddressType -> String
$cshow :: SetIpAddressType -> String
showsPrec :: Int -> SetIpAddressType -> ShowS
$cshowsPrec :: Int -> SetIpAddressType -> ShowS
Prelude.Show, (forall x. SetIpAddressType -> Rep SetIpAddressType x)
-> (forall x. Rep SetIpAddressType x -> SetIpAddressType)
-> Generic SetIpAddressType
forall x. Rep SetIpAddressType x -> SetIpAddressType
forall x. SetIpAddressType -> Rep SetIpAddressType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetIpAddressType x -> SetIpAddressType
$cfrom :: forall x. SetIpAddressType -> Rep SetIpAddressType x
Prelude.Generic)

-- |
-- Create a value of 'SetIpAddressType' 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:
--
-- 'loadBalancerArn', 'setIpAddressType_loadBalancerArn' - The Amazon Resource Name (ARN) of the load balancer.
--
-- 'ipAddressType', 'setIpAddressType_ipAddressType' - The IP address type. The possible values are @ipv4@ (for IPv4 addresses)
-- and @dualstack@ (for IPv4 and IPv6 addresses). Internal load balancers
-- must use @ipv4@. You can’t specify @dualstack@ for a load balancer with
-- a UDP or TCP_UDP listener.
newSetIpAddressType ::
  -- | 'loadBalancerArn'
  Prelude.Text ->
  -- | 'ipAddressType'
  IpAddressType ->
  SetIpAddressType
newSetIpAddressType :: Text -> IpAddressType -> SetIpAddressType
newSetIpAddressType Text
pLoadBalancerArn_ IpAddressType
pIpAddressType_ =
  SetIpAddressType' :: Text -> IpAddressType -> SetIpAddressType
SetIpAddressType'
    { $sel:loadBalancerArn:SetIpAddressType' :: Text
loadBalancerArn =
        Text
pLoadBalancerArn_,
      $sel:ipAddressType:SetIpAddressType' :: IpAddressType
ipAddressType = IpAddressType
pIpAddressType_
    }

-- | The Amazon Resource Name (ARN) of the load balancer.
setIpAddressType_loadBalancerArn :: Lens.Lens' SetIpAddressType Prelude.Text
setIpAddressType_loadBalancerArn :: (Text -> f Text) -> SetIpAddressType -> f SetIpAddressType
setIpAddressType_loadBalancerArn = (SetIpAddressType -> Text)
-> (SetIpAddressType -> Text -> SetIpAddressType)
-> Lens SetIpAddressType SetIpAddressType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetIpAddressType' {Text
loadBalancerArn :: Text
$sel:loadBalancerArn:SetIpAddressType' :: SetIpAddressType -> Text
loadBalancerArn} -> Text
loadBalancerArn) (\s :: SetIpAddressType
s@SetIpAddressType' {} Text
a -> SetIpAddressType
s {$sel:loadBalancerArn:SetIpAddressType' :: Text
loadBalancerArn = Text
a} :: SetIpAddressType)

-- | The IP address type. The possible values are @ipv4@ (for IPv4 addresses)
-- and @dualstack@ (for IPv4 and IPv6 addresses). Internal load balancers
-- must use @ipv4@. You can’t specify @dualstack@ for a load balancer with
-- a UDP or TCP_UDP listener.
setIpAddressType_ipAddressType :: Lens.Lens' SetIpAddressType IpAddressType
setIpAddressType_ipAddressType :: (IpAddressType -> f IpAddressType)
-> SetIpAddressType -> f SetIpAddressType
setIpAddressType_ipAddressType = (SetIpAddressType -> IpAddressType)
-> (SetIpAddressType -> IpAddressType -> SetIpAddressType)
-> Lens
     SetIpAddressType SetIpAddressType IpAddressType IpAddressType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetIpAddressType' {IpAddressType
ipAddressType :: IpAddressType
$sel:ipAddressType:SetIpAddressType' :: SetIpAddressType -> IpAddressType
ipAddressType} -> IpAddressType
ipAddressType) (\s :: SetIpAddressType
s@SetIpAddressType' {} IpAddressType
a -> SetIpAddressType
s {$sel:ipAddressType:SetIpAddressType' :: IpAddressType
ipAddressType = IpAddressType
a} :: SetIpAddressType)

instance Core.AWSRequest SetIpAddressType where
  type
    AWSResponse SetIpAddressType =
      SetIpAddressTypeResponse
  request :: SetIpAddressType -> Request SetIpAddressType
request = Service -> SetIpAddressType -> Request SetIpAddressType
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetIpAddressType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetIpAddressType)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse SetIpAddressType))
-> Logger
-> Service
-> Proxy SetIpAddressType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetIpAddressType)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"SetIpAddressTypeResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe IpAddressType -> Int -> SetIpAddressTypeResponse
SetIpAddressTypeResponse'
            (Maybe IpAddressType -> Int -> SetIpAddressTypeResponse)
-> Either String (Maybe IpAddressType)
-> Either String (Int -> SetIpAddressTypeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe IpAddressType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IpAddressType")
            Either String (Int -> SetIpAddressTypeResponse)
-> Either String Int -> Either String SetIpAddressTypeResponse
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 SetIpAddressType

instance Prelude.NFData SetIpAddressType

instance Core.ToHeaders SetIpAddressType where
  toHeaders :: SetIpAddressType -> ResponseHeaders
toHeaders = ResponseHeaders -> SetIpAddressType -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery SetIpAddressType where
  toQuery :: SetIpAddressType -> QueryString
toQuery SetIpAddressType' {Text
IpAddressType
ipAddressType :: IpAddressType
loadBalancerArn :: Text
$sel:ipAddressType:SetIpAddressType' :: SetIpAddressType -> IpAddressType
$sel:loadBalancerArn:SetIpAddressType' :: SetIpAddressType -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetIpAddressType" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"LoadBalancerArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
loadBalancerArn,
        ByteString
"IpAddressType" ByteString -> IpAddressType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: IpAddressType
ipAddressType
      ]

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

-- |
-- Create a value of 'SetIpAddressTypeResponse' 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:
--
-- 'ipAddressType', 'setIpAddressTypeResponse_ipAddressType' - The IP address type.
--
-- 'httpStatus', 'setIpAddressTypeResponse_httpStatus' - The response's http status code.
newSetIpAddressTypeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SetIpAddressTypeResponse
newSetIpAddressTypeResponse :: Int -> SetIpAddressTypeResponse
newSetIpAddressTypeResponse Int
pHttpStatus_ =
  SetIpAddressTypeResponse' :: Maybe IpAddressType -> Int -> SetIpAddressTypeResponse
SetIpAddressTypeResponse'
    { $sel:ipAddressType:SetIpAddressTypeResponse' :: Maybe IpAddressType
ipAddressType =
        Maybe IpAddressType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SetIpAddressTypeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The IP address type.
setIpAddressTypeResponse_ipAddressType :: Lens.Lens' SetIpAddressTypeResponse (Prelude.Maybe IpAddressType)
setIpAddressTypeResponse_ipAddressType :: (Maybe IpAddressType -> f (Maybe IpAddressType))
-> SetIpAddressTypeResponse -> f SetIpAddressTypeResponse
setIpAddressTypeResponse_ipAddressType = (SetIpAddressTypeResponse -> Maybe IpAddressType)
-> (SetIpAddressTypeResponse
    -> Maybe IpAddressType -> SetIpAddressTypeResponse)
-> Lens
     SetIpAddressTypeResponse
     SetIpAddressTypeResponse
     (Maybe IpAddressType)
     (Maybe IpAddressType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetIpAddressTypeResponse' {Maybe IpAddressType
ipAddressType :: Maybe IpAddressType
$sel:ipAddressType:SetIpAddressTypeResponse' :: SetIpAddressTypeResponse -> Maybe IpAddressType
ipAddressType} -> Maybe IpAddressType
ipAddressType) (\s :: SetIpAddressTypeResponse
s@SetIpAddressTypeResponse' {} Maybe IpAddressType
a -> SetIpAddressTypeResponse
s {$sel:ipAddressType:SetIpAddressTypeResponse' :: Maybe IpAddressType
ipAddressType = Maybe IpAddressType
a} :: SetIpAddressTypeResponse)

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

instance Prelude.NFData SetIpAddressTypeResponse