{-# 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.OpsWorks.UpdateElasticIp
-- 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)
--
-- Updates a registered Elastic IP address\'s name. For more information,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/resources.html Resource Management>.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.UpdateElasticIp
  ( -- * Creating a Request
    UpdateElasticIp (..),
    newUpdateElasticIp,

    -- * Request Lenses
    updateElasticIp_name,
    updateElasticIp_elasticIp,

    -- * Destructuring the Response
    UpdateElasticIpResponse (..),
    newUpdateElasticIpResponse,
  )
where

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

-- | /See:/ 'newUpdateElasticIp' smart constructor.
data UpdateElasticIp = UpdateElasticIp'
  { -- | The new name.
    UpdateElasticIp -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The IP address for which you want to update the name.
    UpdateElasticIp -> Text
elasticIp :: Prelude.Text
  }
  deriving (UpdateElasticIp -> UpdateElasticIp -> Bool
(UpdateElasticIp -> UpdateElasticIp -> Bool)
-> (UpdateElasticIp -> UpdateElasticIp -> Bool)
-> Eq UpdateElasticIp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateElasticIp -> UpdateElasticIp -> Bool
$c/= :: UpdateElasticIp -> UpdateElasticIp -> Bool
== :: UpdateElasticIp -> UpdateElasticIp -> Bool
$c== :: UpdateElasticIp -> UpdateElasticIp -> Bool
Prelude.Eq, ReadPrec [UpdateElasticIp]
ReadPrec UpdateElasticIp
Int -> ReadS UpdateElasticIp
ReadS [UpdateElasticIp]
(Int -> ReadS UpdateElasticIp)
-> ReadS [UpdateElasticIp]
-> ReadPrec UpdateElasticIp
-> ReadPrec [UpdateElasticIp]
-> Read UpdateElasticIp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateElasticIp]
$creadListPrec :: ReadPrec [UpdateElasticIp]
readPrec :: ReadPrec UpdateElasticIp
$creadPrec :: ReadPrec UpdateElasticIp
readList :: ReadS [UpdateElasticIp]
$creadList :: ReadS [UpdateElasticIp]
readsPrec :: Int -> ReadS UpdateElasticIp
$creadsPrec :: Int -> ReadS UpdateElasticIp
Prelude.Read, Int -> UpdateElasticIp -> ShowS
[UpdateElasticIp] -> ShowS
UpdateElasticIp -> String
(Int -> UpdateElasticIp -> ShowS)
-> (UpdateElasticIp -> String)
-> ([UpdateElasticIp] -> ShowS)
-> Show UpdateElasticIp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateElasticIp] -> ShowS
$cshowList :: [UpdateElasticIp] -> ShowS
show :: UpdateElasticIp -> String
$cshow :: UpdateElasticIp -> String
showsPrec :: Int -> UpdateElasticIp -> ShowS
$cshowsPrec :: Int -> UpdateElasticIp -> ShowS
Prelude.Show, (forall x. UpdateElasticIp -> Rep UpdateElasticIp x)
-> (forall x. Rep UpdateElasticIp x -> UpdateElasticIp)
-> Generic UpdateElasticIp
forall x. Rep UpdateElasticIp x -> UpdateElasticIp
forall x. UpdateElasticIp -> Rep UpdateElasticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateElasticIp x -> UpdateElasticIp
$cfrom :: forall x. UpdateElasticIp -> Rep UpdateElasticIp x
Prelude.Generic)

-- |
-- Create a value of 'UpdateElasticIp' 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:
--
-- 'name', 'updateElasticIp_name' - The new name.
--
-- 'elasticIp', 'updateElasticIp_elasticIp' - The IP address for which you want to update the name.
newUpdateElasticIp ::
  -- | 'elasticIp'
  Prelude.Text ->
  UpdateElasticIp
newUpdateElasticIp :: Text -> UpdateElasticIp
newUpdateElasticIp Text
pElasticIp_ =
  UpdateElasticIp' :: Maybe Text -> Text -> UpdateElasticIp
UpdateElasticIp'
    { $sel:name:UpdateElasticIp' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:elasticIp:UpdateElasticIp' :: Text
elasticIp = Text
pElasticIp_
    }

-- | The new name.
updateElasticIp_name :: Lens.Lens' UpdateElasticIp (Prelude.Maybe Prelude.Text)
updateElasticIp_name :: (Maybe Text -> f (Maybe Text))
-> UpdateElasticIp -> f UpdateElasticIp
updateElasticIp_name = (UpdateElasticIp -> Maybe Text)
-> (UpdateElasticIp -> Maybe Text -> UpdateElasticIp)
-> Lens UpdateElasticIp UpdateElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateElasticIp' {Maybe Text
name :: Maybe Text
$sel:name:UpdateElasticIp' :: UpdateElasticIp -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateElasticIp
s@UpdateElasticIp' {} Maybe Text
a -> UpdateElasticIp
s {$sel:name:UpdateElasticIp' :: Maybe Text
name = Maybe Text
a} :: UpdateElasticIp)

-- | The IP address for which you want to update the name.
updateElasticIp_elasticIp :: Lens.Lens' UpdateElasticIp Prelude.Text
updateElasticIp_elasticIp :: (Text -> f Text) -> UpdateElasticIp -> f UpdateElasticIp
updateElasticIp_elasticIp = (UpdateElasticIp -> Text)
-> (UpdateElasticIp -> Text -> UpdateElasticIp)
-> Lens UpdateElasticIp UpdateElasticIp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateElasticIp' {Text
elasticIp :: Text
$sel:elasticIp:UpdateElasticIp' :: UpdateElasticIp -> Text
elasticIp} -> Text
elasticIp) (\s :: UpdateElasticIp
s@UpdateElasticIp' {} Text
a -> UpdateElasticIp
s {$sel:elasticIp:UpdateElasticIp' :: Text
elasticIp = Text
a} :: UpdateElasticIp)

instance Core.AWSRequest UpdateElasticIp where
  type
    AWSResponse UpdateElasticIp =
      UpdateElasticIpResponse
  request :: UpdateElasticIp -> Request UpdateElasticIp
request = Service -> UpdateElasticIp -> Request UpdateElasticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateElasticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateElasticIp)))
response =
    AWSResponse UpdateElasticIp
-> Logger
-> Service
-> Proxy UpdateElasticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateElasticIp)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateElasticIp
UpdateElasticIpResponse
UpdateElasticIpResponse'

instance Prelude.Hashable UpdateElasticIp

instance Prelude.NFData UpdateElasticIp

instance Core.ToHeaders UpdateElasticIp where
  toHeaders :: UpdateElasticIp -> [Header]
toHeaders =
    [Header] -> UpdateElasticIp -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.UpdateElasticIp" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateElasticIp where
  toJSON :: UpdateElasticIp -> Value
toJSON UpdateElasticIp' {Maybe Text
Text
elasticIp :: Text
name :: Maybe Text
$sel:elasticIp:UpdateElasticIp' :: UpdateElasticIp -> Text
$sel:name:UpdateElasticIp' :: UpdateElasticIp -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ElasticIp" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
elasticIp)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateElasticIpResponse' 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.
newUpdateElasticIpResponse ::
  UpdateElasticIpResponse
newUpdateElasticIpResponse :: UpdateElasticIpResponse
newUpdateElasticIpResponse = UpdateElasticIpResponse
UpdateElasticIpResponse'

instance Prelude.NFData UpdateElasticIpResponse