{-# 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.Redshift.ModifyClusterSubnetGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Modifies a cluster subnet group to include the specified list of VPC
-- subnets. The operation replaces the existing list of subnets with the
-- new list of subnets.
module Amazonka.Redshift.ModifyClusterSubnetGroup
  ( -- * Creating a Request
    ModifyClusterSubnetGroup (..),
    newModifyClusterSubnetGroup,

    -- * Request Lenses
    modifyClusterSubnetGroup_description,
    modifyClusterSubnetGroup_clusterSubnetGroupName,
    modifyClusterSubnetGroup_subnetIds,

    -- * Destructuring the Response
    ModifyClusterSubnetGroupResponse (..),
    newModifyClusterSubnetGroupResponse,

    -- * Response Lenses
    modifyClusterSubnetGroupResponse_clusterSubnetGroup,
    modifyClusterSubnetGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newModifyClusterSubnetGroup' smart constructor.
data ModifyClusterSubnetGroup = ModifyClusterSubnetGroup'
  { -- | A text description of the subnet group to be modified.
    ModifyClusterSubnetGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the subnet group to be modified.
    ModifyClusterSubnetGroup -> Text
clusterSubnetGroupName :: Prelude.Text,
    -- | An array of VPC subnet IDs. A maximum of 20 subnets can be modified in a
    -- single request.
    ModifyClusterSubnetGroup -> [Text]
subnetIds :: [Prelude.Text]
  }
  deriving (ModifyClusterSubnetGroup -> ModifyClusterSubnetGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyClusterSubnetGroup -> ModifyClusterSubnetGroup -> Bool
$c/= :: ModifyClusterSubnetGroup -> ModifyClusterSubnetGroup -> Bool
== :: ModifyClusterSubnetGroup -> ModifyClusterSubnetGroup -> Bool
$c== :: ModifyClusterSubnetGroup -> ModifyClusterSubnetGroup -> Bool
Prelude.Eq, ReadPrec [ModifyClusterSubnetGroup]
ReadPrec ModifyClusterSubnetGroup
Int -> ReadS ModifyClusterSubnetGroup
ReadS [ModifyClusterSubnetGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyClusterSubnetGroup]
$creadListPrec :: ReadPrec [ModifyClusterSubnetGroup]
readPrec :: ReadPrec ModifyClusterSubnetGroup
$creadPrec :: ReadPrec ModifyClusterSubnetGroup
readList :: ReadS [ModifyClusterSubnetGroup]
$creadList :: ReadS [ModifyClusterSubnetGroup]
readsPrec :: Int -> ReadS ModifyClusterSubnetGroup
$creadsPrec :: Int -> ReadS ModifyClusterSubnetGroup
Prelude.Read, Int -> ModifyClusterSubnetGroup -> ShowS
[ModifyClusterSubnetGroup] -> ShowS
ModifyClusterSubnetGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyClusterSubnetGroup] -> ShowS
$cshowList :: [ModifyClusterSubnetGroup] -> ShowS
show :: ModifyClusterSubnetGroup -> String
$cshow :: ModifyClusterSubnetGroup -> String
showsPrec :: Int -> ModifyClusterSubnetGroup -> ShowS
$cshowsPrec :: Int -> ModifyClusterSubnetGroup -> ShowS
Prelude.Show, forall x.
Rep ModifyClusterSubnetGroup x -> ModifyClusterSubnetGroup
forall x.
ModifyClusterSubnetGroup -> Rep ModifyClusterSubnetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifyClusterSubnetGroup x -> ModifyClusterSubnetGroup
$cfrom :: forall x.
ModifyClusterSubnetGroup -> Rep ModifyClusterSubnetGroup x
Prelude.Generic)

-- |
-- Create a value of 'ModifyClusterSubnetGroup' 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:
--
-- 'description', 'modifyClusterSubnetGroup_description' - A text description of the subnet group to be modified.
--
-- 'clusterSubnetGroupName', 'modifyClusterSubnetGroup_clusterSubnetGroupName' - The name of the subnet group to be modified.
--
-- 'subnetIds', 'modifyClusterSubnetGroup_subnetIds' - An array of VPC subnet IDs. A maximum of 20 subnets can be modified in a
-- single request.
newModifyClusterSubnetGroup ::
  -- | 'clusterSubnetGroupName'
  Prelude.Text ->
  ModifyClusterSubnetGroup
newModifyClusterSubnetGroup :: Text -> ModifyClusterSubnetGroup
newModifyClusterSubnetGroup Text
pClusterSubnetGroupName_ =
  ModifyClusterSubnetGroup'
    { $sel:description:ModifyClusterSubnetGroup' :: Maybe Text
description =
        forall a. Maybe a
Prelude.Nothing,
      $sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: Text
clusterSubnetGroupName = Text
pClusterSubnetGroupName_,
      $sel:subnetIds:ModifyClusterSubnetGroup' :: [Text]
subnetIds = forall a. Monoid a => a
Prelude.mempty
    }

-- | A text description of the subnet group to be modified.
modifyClusterSubnetGroup_description :: Lens.Lens' ModifyClusterSubnetGroup (Prelude.Maybe Prelude.Text)
modifyClusterSubnetGroup_description :: Lens' ModifyClusterSubnetGroup (Maybe Text)
modifyClusterSubnetGroup_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterSubnetGroup' {Maybe Text
description :: Maybe Text
$sel:description:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: ModifyClusterSubnetGroup
s@ModifyClusterSubnetGroup' {} Maybe Text
a -> ModifyClusterSubnetGroup
s {$sel:description:ModifyClusterSubnetGroup' :: Maybe Text
description = Maybe Text
a} :: ModifyClusterSubnetGroup)

-- | The name of the subnet group to be modified.
modifyClusterSubnetGroup_clusterSubnetGroupName :: Lens.Lens' ModifyClusterSubnetGroup Prelude.Text
modifyClusterSubnetGroup_clusterSubnetGroupName :: Lens' ModifyClusterSubnetGroup Text
modifyClusterSubnetGroup_clusterSubnetGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterSubnetGroup' {Text
clusterSubnetGroupName :: Text
$sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Text
clusterSubnetGroupName} -> Text
clusterSubnetGroupName) (\s :: ModifyClusterSubnetGroup
s@ModifyClusterSubnetGroup' {} Text
a -> ModifyClusterSubnetGroup
s {$sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: Text
clusterSubnetGroupName = Text
a} :: ModifyClusterSubnetGroup)

-- | An array of VPC subnet IDs. A maximum of 20 subnets can be modified in a
-- single request.
modifyClusterSubnetGroup_subnetIds :: Lens.Lens' ModifyClusterSubnetGroup [Prelude.Text]
modifyClusterSubnetGroup_subnetIds :: Lens' ModifyClusterSubnetGroup [Text]
modifyClusterSubnetGroup_subnetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterSubnetGroup' {[Text]
subnetIds :: [Text]
$sel:subnetIds:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> [Text]
subnetIds} -> [Text]
subnetIds) (\s :: ModifyClusterSubnetGroup
s@ModifyClusterSubnetGroup' {} [Text]
a -> ModifyClusterSubnetGroup
s {$sel:subnetIds:ModifyClusterSubnetGroup' :: [Text]
subnetIds = [Text]
a} :: ModifyClusterSubnetGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ModifyClusterSubnetGroup where
  type
    AWSResponse ModifyClusterSubnetGroup =
      ModifyClusterSubnetGroupResponse
  request :: (Service -> Service)
-> ModifyClusterSubnetGroup -> Request ModifyClusterSubnetGroup
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ModifyClusterSubnetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyClusterSubnetGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyClusterSubnetGroupResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ClusterSubnetGroup -> Int -> ModifyClusterSubnetGroupResponse
ModifyClusterSubnetGroupResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ClusterSubnetGroup")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ModifyClusterSubnetGroup where
  hashWithSalt :: Int -> ModifyClusterSubnetGroup -> Int
hashWithSalt Int
_salt ModifyClusterSubnetGroup' {[Text]
Maybe Text
Text
subnetIds :: [Text]
clusterSubnetGroupName :: Text
description :: Maybe Text
$sel:subnetIds:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> [Text]
$sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Text
$sel:description:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterSubnetGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
subnetIds

instance Prelude.NFData ModifyClusterSubnetGroup where
  rnf :: ModifyClusterSubnetGroup -> ()
rnf ModifyClusterSubnetGroup' {[Text]
Maybe Text
Text
subnetIds :: [Text]
clusterSubnetGroupName :: Text
description :: Maybe Text
$sel:subnetIds:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> [Text]
$sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Text
$sel:description:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clusterSubnetGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
subnetIds

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

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

instance Data.ToQuery ModifyClusterSubnetGroup where
  toQuery :: ModifyClusterSubnetGroup -> QueryString
toQuery ModifyClusterSubnetGroup' {[Text]
Maybe Text
Text
subnetIds :: [Text]
clusterSubnetGroupName :: Text
description :: Maybe Text
$sel:subnetIds:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> [Text]
$sel:clusterSubnetGroupName:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Text
$sel:description:ModifyClusterSubnetGroup' :: ModifyClusterSubnetGroup -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ModifyClusterSubnetGroup" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"Description" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
description,
        ByteString
"ClusterSubnetGroupName"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
clusterSubnetGroupName,
        ByteString
"SubnetIds"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"SubnetIdentifier" [Text]
subnetIds
      ]

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

-- |
-- Create a value of 'ModifyClusterSubnetGroupResponse' 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:
--
-- 'clusterSubnetGroup', 'modifyClusterSubnetGroupResponse_clusterSubnetGroup' - Undocumented member.
--
-- 'httpStatus', 'modifyClusterSubnetGroupResponse_httpStatus' - The response's http status code.
newModifyClusterSubnetGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ModifyClusterSubnetGroupResponse
newModifyClusterSubnetGroupResponse :: Int -> ModifyClusterSubnetGroupResponse
newModifyClusterSubnetGroupResponse Int
pHttpStatus_ =
  ModifyClusterSubnetGroupResponse'
    { $sel:clusterSubnetGroup:ModifyClusterSubnetGroupResponse' :: Maybe ClusterSubnetGroup
clusterSubnetGroup =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ModifyClusterSubnetGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
modifyClusterSubnetGroupResponse_clusterSubnetGroup :: Lens.Lens' ModifyClusterSubnetGroupResponse (Prelude.Maybe ClusterSubnetGroup)
modifyClusterSubnetGroupResponse_clusterSubnetGroup :: Lens' ModifyClusterSubnetGroupResponse (Maybe ClusterSubnetGroup)
modifyClusterSubnetGroupResponse_clusterSubnetGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterSubnetGroupResponse' {Maybe ClusterSubnetGroup
clusterSubnetGroup :: Maybe ClusterSubnetGroup
$sel:clusterSubnetGroup:ModifyClusterSubnetGroupResponse' :: ModifyClusterSubnetGroupResponse -> Maybe ClusterSubnetGroup
clusterSubnetGroup} -> Maybe ClusterSubnetGroup
clusterSubnetGroup) (\s :: ModifyClusterSubnetGroupResponse
s@ModifyClusterSubnetGroupResponse' {} Maybe ClusterSubnetGroup
a -> ModifyClusterSubnetGroupResponse
s {$sel:clusterSubnetGroup:ModifyClusterSubnetGroupResponse' :: Maybe ClusterSubnetGroup
clusterSubnetGroup = Maybe ClusterSubnetGroup
a} :: ModifyClusterSubnetGroupResponse)

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

instance
  Prelude.NFData
    ModifyClusterSubnetGroupResponse
  where
  rnf :: ModifyClusterSubnetGroupResponse -> ()
rnf ModifyClusterSubnetGroupResponse' {Int
Maybe ClusterSubnetGroup
httpStatus :: Int
clusterSubnetGroup :: Maybe ClusterSubnetGroup
$sel:httpStatus:ModifyClusterSubnetGroupResponse' :: ModifyClusterSubnetGroupResponse -> Int
$sel:clusterSubnetGroup:ModifyClusterSubnetGroupResponse' :: ModifyClusterSubnetGroupResponse -> Maybe ClusterSubnetGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ClusterSubnetGroup
clusterSubnetGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus