{-# 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.PinpointEmail.PutDedicatedIpWarmupAttributes
-- 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)
module Amazonka.PinpointEmail.PutDedicatedIpWarmupAttributes
  ( -- * Creating a Request
    PutDedicatedIpWarmupAttributes (..),
    newPutDedicatedIpWarmupAttributes,

    -- * Request Lenses
    putDedicatedIpWarmupAttributes_ip,
    putDedicatedIpWarmupAttributes_warmupPercentage,

    -- * Destructuring the Response
    PutDedicatedIpWarmupAttributesResponse (..),
    newPutDedicatedIpWarmupAttributesResponse,

    -- * Response Lenses
    putDedicatedIpWarmupAttributesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.PinpointEmail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | A request to change the warm-up attributes for a dedicated IP address.
-- This operation is useful when you want to resume the warm-up process for
-- an existing IP address.
--
-- /See:/ 'newPutDedicatedIpWarmupAttributes' smart constructor.
data PutDedicatedIpWarmupAttributes = PutDedicatedIpWarmupAttributes'
  { -- | The dedicated IP address that you want to update the warm-up attributes
    -- for.
    PutDedicatedIpWarmupAttributes -> Text
ip :: Prelude.Text,
    -- | The warm-up percentage that you want to associate with the dedicated IP
    -- address.
    PutDedicatedIpWarmupAttributes -> Int
warmupPercentage :: Prelude.Int
  }
  deriving (PutDedicatedIpWarmupAttributes
-> PutDedicatedIpWarmupAttributes -> Bool
(PutDedicatedIpWarmupAttributes
 -> PutDedicatedIpWarmupAttributes -> Bool)
-> (PutDedicatedIpWarmupAttributes
    -> PutDedicatedIpWarmupAttributes -> Bool)
-> Eq PutDedicatedIpWarmupAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDedicatedIpWarmupAttributes
-> PutDedicatedIpWarmupAttributes -> Bool
$c/= :: PutDedicatedIpWarmupAttributes
-> PutDedicatedIpWarmupAttributes -> Bool
== :: PutDedicatedIpWarmupAttributes
-> PutDedicatedIpWarmupAttributes -> Bool
$c== :: PutDedicatedIpWarmupAttributes
-> PutDedicatedIpWarmupAttributes -> Bool
Prelude.Eq, ReadPrec [PutDedicatedIpWarmupAttributes]
ReadPrec PutDedicatedIpWarmupAttributes
Int -> ReadS PutDedicatedIpWarmupAttributes
ReadS [PutDedicatedIpWarmupAttributes]
(Int -> ReadS PutDedicatedIpWarmupAttributes)
-> ReadS [PutDedicatedIpWarmupAttributes]
-> ReadPrec PutDedicatedIpWarmupAttributes
-> ReadPrec [PutDedicatedIpWarmupAttributes]
-> Read PutDedicatedIpWarmupAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDedicatedIpWarmupAttributes]
$creadListPrec :: ReadPrec [PutDedicatedIpWarmupAttributes]
readPrec :: ReadPrec PutDedicatedIpWarmupAttributes
$creadPrec :: ReadPrec PutDedicatedIpWarmupAttributes
readList :: ReadS [PutDedicatedIpWarmupAttributes]
$creadList :: ReadS [PutDedicatedIpWarmupAttributes]
readsPrec :: Int -> ReadS PutDedicatedIpWarmupAttributes
$creadsPrec :: Int -> ReadS PutDedicatedIpWarmupAttributes
Prelude.Read, Int -> PutDedicatedIpWarmupAttributes -> ShowS
[PutDedicatedIpWarmupAttributes] -> ShowS
PutDedicatedIpWarmupAttributes -> String
(Int -> PutDedicatedIpWarmupAttributes -> ShowS)
-> (PutDedicatedIpWarmupAttributes -> String)
-> ([PutDedicatedIpWarmupAttributes] -> ShowS)
-> Show PutDedicatedIpWarmupAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDedicatedIpWarmupAttributes] -> ShowS
$cshowList :: [PutDedicatedIpWarmupAttributes] -> ShowS
show :: PutDedicatedIpWarmupAttributes -> String
$cshow :: PutDedicatedIpWarmupAttributes -> String
showsPrec :: Int -> PutDedicatedIpWarmupAttributes -> ShowS
$cshowsPrec :: Int -> PutDedicatedIpWarmupAttributes -> ShowS
Prelude.Show, (forall x.
 PutDedicatedIpWarmupAttributes
 -> Rep PutDedicatedIpWarmupAttributes x)
-> (forall x.
    Rep PutDedicatedIpWarmupAttributes x
    -> PutDedicatedIpWarmupAttributes)
-> Generic PutDedicatedIpWarmupAttributes
forall x.
Rep PutDedicatedIpWarmupAttributes x
-> PutDedicatedIpWarmupAttributes
forall x.
PutDedicatedIpWarmupAttributes
-> Rep PutDedicatedIpWarmupAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutDedicatedIpWarmupAttributes x
-> PutDedicatedIpWarmupAttributes
$cfrom :: forall x.
PutDedicatedIpWarmupAttributes
-> Rep PutDedicatedIpWarmupAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutDedicatedIpWarmupAttributes' 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:
--
-- 'ip', 'putDedicatedIpWarmupAttributes_ip' - The dedicated IP address that you want to update the warm-up attributes
-- for.
--
-- 'warmupPercentage', 'putDedicatedIpWarmupAttributes_warmupPercentage' - The warm-up percentage that you want to associate with the dedicated IP
-- address.
newPutDedicatedIpWarmupAttributes ::
  -- | 'ip'
  Prelude.Text ->
  -- | 'warmupPercentage'
  Prelude.Int ->
  PutDedicatedIpWarmupAttributes
newPutDedicatedIpWarmupAttributes :: Text -> Int -> PutDedicatedIpWarmupAttributes
newPutDedicatedIpWarmupAttributes
  Text
pIp_
  Int
pWarmupPercentage_ =
    PutDedicatedIpWarmupAttributes' :: Text -> Int -> PutDedicatedIpWarmupAttributes
PutDedicatedIpWarmupAttributes'
      { $sel:ip:PutDedicatedIpWarmupAttributes' :: Text
ip = Text
pIp_,
        $sel:warmupPercentage:PutDedicatedIpWarmupAttributes' :: Int
warmupPercentage = Int
pWarmupPercentage_
      }

-- | The dedicated IP address that you want to update the warm-up attributes
-- for.
putDedicatedIpWarmupAttributes_ip :: Lens.Lens' PutDedicatedIpWarmupAttributes Prelude.Text
putDedicatedIpWarmupAttributes_ip :: (Text -> f Text)
-> PutDedicatedIpWarmupAttributes
-> f PutDedicatedIpWarmupAttributes
putDedicatedIpWarmupAttributes_ip = (PutDedicatedIpWarmupAttributes -> Text)
-> (PutDedicatedIpWarmupAttributes
    -> Text -> PutDedicatedIpWarmupAttributes)
-> Lens
     PutDedicatedIpWarmupAttributes
     PutDedicatedIpWarmupAttributes
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDedicatedIpWarmupAttributes' {Text
ip :: Text
$sel:ip:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> Text
ip} -> Text
ip) (\s :: PutDedicatedIpWarmupAttributes
s@PutDedicatedIpWarmupAttributes' {} Text
a -> PutDedicatedIpWarmupAttributes
s {$sel:ip:PutDedicatedIpWarmupAttributes' :: Text
ip = Text
a} :: PutDedicatedIpWarmupAttributes)

-- | The warm-up percentage that you want to associate with the dedicated IP
-- address.
putDedicatedIpWarmupAttributes_warmupPercentage :: Lens.Lens' PutDedicatedIpWarmupAttributes Prelude.Int
putDedicatedIpWarmupAttributes_warmupPercentage :: (Int -> f Int)
-> PutDedicatedIpWarmupAttributes
-> f PutDedicatedIpWarmupAttributes
putDedicatedIpWarmupAttributes_warmupPercentage = (PutDedicatedIpWarmupAttributes -> Int)
-> (PutDedicatedIpWarmupAttributes
    -> Int -> PutDedicatedIpWarmupAttributes)
-> Lens
     PutDedicatedIpWarmupAttributes
     PutDedicatedIpWarmupAttributes
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDedicatedIpWarmupAttributes' {Int
warmupPercentage :: Int
$sel:warmupPercentage:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> Int
warmupPercentage} -> Int
warmupPercentage) (\s :: PutDedicatedIpWarmupAttributes
s@PutDedicatedIpWarmupAttributes' {} Int
a -> PutDedicatedIpWarmupAttributes
s {$sel:warmupPercentage:PutDedicatedIpWarmupAttributes' :: Int
warmupPercentage = Int
a} :: PutDedicatedIpWarmupAttributes)

instance
  Core.AWSRequest
    PutDedicatedIpWarmupAttributes
  where
  type
    AWSResponse PutDedicatedIpWarmupAttributes =
      PutDedicatedIpWarmupAttributesResponse
  request :: PutDedicatedIpWarmupAttributes
-> Request PutDedicatedIpWarmupAttributes
request = Service
-> PutDedicatedIpWarmupAttributes
-> Request PutDedicatedIpWarmupAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutDedicatedIpWarmupAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutDedicatedIpWarmupAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutDedicatedIpWarmupAttributes))
-> Logger
-> Service
-> Proxy PutDedicatedIpWarmupAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutDedicatedIpWarmupAttributes)))
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 -> PutDedicatedIpWarmupAttributesResponse
PutDedicatedIpWarmupAttributesResponse'
            (Int -> PutDedicatedIpWarmupAttributesResponse)
-> Either String Int
-> Either String PutDedicatedIpWarmupAttributesResponse
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
    PutDedicatedIpWarmupAttributes

instance
  Prelude.NFData
    PutDedicatedIpWarmupAttributes

instance
  Core.ToHeaders
    PutDedicatedIpWarmupAttributes
  where
  toHeaders :: PutDedicatedIpWarmupAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutDedicatedIpWarmupAttributes -> 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 PutDedicatedIpWarmupAttributes where
  toJSON :: PutDedicatedIpWarmupAttributes -> Value
toJSON PutDedicatedIpWarmupAttributes' {Int
Text
warmupPercentage :: Int
ip :: Text
$sel:warmupPercentage:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> Int
$sel:ip:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> 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
"WarmupPercentage" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
warmupPercentage)
          ]
      )

instance Core.ToPath PutDedicatedIpWarmupAttributes where
  toPath :: PutDedicatedIpWarmupAttributes -> ByteString
toPath PutDedicatedIpWarmupAttributes' {Int
Text
warmupPercentage :: Int
ip :: Text
$sel:warmupPercentage:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> Int
$sel:ip:PutDedicatedIpWarmupAttributes' :: PutDedicatedIpWarmupAttributes -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/email/dedicated-ips/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
ip, ByteString
"/warmup"]

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

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutDedicatedIpWarmupAttributesResponse' smart constructor.
data PutDedicatedIpWarmupAttributesResponse = PutDedicatedIpWarmupAttributesResponse'
  { -- | The response's http status code.
    PutDedicatedIpWarmupAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutDedicatedIpWarmupAttributesResponse
-> PutDedicatedIpWarmupAttributesResponse -> Bool
(PutDedicatedIpWarmupAttributesResponse
 -> PutDedicatedIpWarmupAttributesResponse -> Bool)
-> (PutDedicatedIpWarmupAttributesResponse
    -> PutDedicatedIpWarmupAttributesResponse -> Bool)
-> Eq PutDedicatedIpWarmupAttributesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDedicatedIpWarmupAttributesResponse
-> PutDedicatedIpWarmupAttributesResponse -> Bool
$c/= :: PutDedicatedIpWarmupAttributesResponse
-> PutDedicatedIpWarmupAttributesResponse -> Bool
== :: PutDedicatedIpWarmupAttributesResponse
-> PutDedicatedIpWarmupAttributesResponse -> Bool
$c== :: PutDedicatedIpWarmupAttributesResponse
-> PutDedicatedIpWarmupAttributesResponse -> Bool
Prelude.Eq, ReadPrec [PutDedicatedIpWarmupAttributesResponse]
ReadPrec PutDedicatedIpWarmupAttributesResponse
Int -> ReadS PutDedicatedIpWarmupAttributesResponse
ReadS [PutDedicatedIpWarmupAttributesResponse]
(Int -> ReadS PutDedicatedIpWarmupAttributesResponse)
-> ReadS [PutDedicatedIpWarmupAttributesResponse]
-> ReadPrec PutDedicatedIpWarmupAttributesResponse
-> ReadPrec [PutDedicatedIpWarmupAttributesResponse]
-> Read PutDedicatedIpWarmupAttributesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDedicatedIpWarmupAttributesResponse]
$creadListPrec :: ReadPrec [PutDedicatedIpWarmupAttributesResponse]
readPrec :: ReadPrec PutDedicatedIpWarmupAttributesResponse
$creadPrec :: ReadPrec PutDedicatedIpWarmupAttributesResponse
readList :: ReadS [PutDedicatedIpWarmupAttributesResponse]
$creadList :: ReadS [PutDedicatedIpWarmupAttributesResponse]
readsPrec :: Int -> ReadS PutDedicatedIpWarmupAttributesResponse
$creadsPrec :: Int -> ReadS PutDedicatedIpWarmupAttributesResponse
Prelude.Read, Int -> PutDedicatedIpWarmupAttributesResponse -> ShowS
[PutDedicatedIpWarmupAttributesResponse] -> ShowS
PutDedicatedIpWarmupAttributesResponse -> String
(Int -> PutDedicatedIpWarmupAttributesResponse -> ShowS)
-> (PutDedicatedIpWarmupAttributesResponse -> String)
-> ([PutDedicatedIpWarmupAttributesResponse] -> ShowS)
-> Show PutDedicatedIpWarmupAttributesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDedicatedIpWarmupAttributesResponse] -> ShowS
$cshowList :: [PutDedicatedIpWarmupAttributesResponse] -> ShowS
show :: PutDedicatedIpWarmupAttributesResponse -> String
$cshow :: PutDedicatedIpWarmupAttributesResponse -> String
showsPrec :: Int -> PutDedicatedIpWarmupAttributesResponse -> ShowS
$cshowsPrec :: Int -> PutDedicatedIpWarmupAttributesResponse -> ShowS
Prelude.Show, (forall x.
 PutDedicatedIpWarmupAttributesResponse
 -> Rep PutDedicatedIpWarmupAttributesResponse x)
-> (forall x.
    Rep PutDedicatedIpWarmupAttributesResponse x
    -> PutDedicatedIpWarmupAttributesResponse)
-> Generic PutDedicatedIpWarmupAttributesResponse
forall x.
Rep PutDedicatedIpWarmupAttributesResponse x
-> PutDedicatedIpWarmupAttributesResponse
forall x.
PutDedicatedIpWarmupAttributesResponse
-> Rep PutDedicatedIpWarmupAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutDedicatedIpWarmupAttributesResponse x
-> PutDedicatedIpWarmupAttributesResponse
$cfrom :: forall x.
PutDedicatedIpWarmupAttributesResponse
-> Rep PutDedicatedIpWarmupAttributesResponse x
Prelude.Generic)

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

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

instance
  Prelude.NFData
    PutDedicatedIpWarmupAttributesResponse