{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:name:UpdateElasticIp' :: Maybe Text
name = 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 :: Lens' UpdateElasticIp (Maybe Text)
updateElasticIp_name = 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 :: Lens' UpdateElasticIp Text
updateElasticIp_elasticIp = 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 :: (Service -> Service) -> UpdateElasticIp -> Request UpdateElasticIp
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 UpdateElasticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateElasticIp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateElasticIpResponse
UpdateElasticIpResponse'

instance Prelude.Hashable UpdateElasticIp where
  hashWithSalt :: Int -> UpdateElasticIp -> Int
hashWithSalt Int
_salt UpdateElasticIp' {Maybe Text
Text
elasticIp :: Text
name :: Maybe Text
$sel:elasticIp:UpdateElasticIp' :: UpdateElasticIp -> Text
$sel:name:UpdateElasticIp' :: UpdateElasticIp -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
elasticIp

instance Prelude.NFData UpdateElasticIp where
  rnf :: UpdateElasticIp -> ()
rnf UpdateElasticIp' {Maybe Text
Text
elasticIp :: Text
name :: Maybe Text
$sel:elasticIp:UpdateElasticIp' :: UpdateElasticIp -> Text
$sel:name:UpdateElasticIp' :: UpdateElasticIp -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
elasticIp

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            forall a. a -> Maybe a
Prelude.Just (Key
"ElasticIp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
elasticIp)
          ]
      )

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

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

-- | /See:/ 'newUpdateElasticIpResponse' smart constructor.
data UpdateElasticIpResponse = UpdateElasticIpResponse'
  {
  }
  deriving (UpdateElasticIpResponse -> UpdateElasticIpResponse -> Bool
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]
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
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. 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 where
  rnf :: UpdateElasticIpResponse -> ()
rnf UpdateElasticIpResponse
_ = ()