{-# 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.DAX.CreateSubnetGroup
-- 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)
--
-- Creates a new subnet group.
module Amazonka.DAX.CreateSubnetGroup
  ( -- * Creating a Request
    CreateSubnetGroup (..),
    newCreateSubnetGroup,

    -- * Request Lenses
    createSubnetGroup_description,
    createSubnetGroup_subnetGroupName,
    createSubnetGroup_subnetIds,

    -- * Destructuring the Response
    CreateSubnetGroupResponse (..),
    newCreateSubnetGroupResponse,

    -- * Response Lenses
    createSubnetGroupResponse_subnetGroup,
    createSubnetGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DAX.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:/ 'newCreateSubnetGroup' smart constructor.
data CreateSubnetGroup = CreateSubnetGroup'
  { -- | A description for the subnet group
    CreateSubnetGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A name for the subnet group. This value is stored as a lowercase string.
    CreateSubnetGroup -> Text
subnetGroupName :: Prelude.Text,
    -- | A list of VPC subnet IDs for the subnet group.
    CreateSubnetGroup -> [Text]
subnetIds :: [Prelude.Text]
  }
  deriving (CreateSubnetGroup -> CreateSubnetGroup -> Bool
(CreateSubnetGroup -> CreateSubnetGroup -> Bool)
-> (CreateSubnetGroup -> CreateSubnetGroup -> Bool)
-> Eq CreateSubnetGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSubnetGroup -> CreateSubnetGroup -> Bool
$c/= :: CreateSubnetGroup -> CreateSubnetGroup -> Bool
== :: CreateSubnetGroup -> CreateSubnetGroup -> Bool
$c== :: CreateSubnetGroup -> CreateSubnetGroup -> Bool
Prelude.Eq, ReadPrec [CreateSubnetGroup]
ReadPrec CreateSubnetGroup
Int -> ReadS CreateSubnetGroup
ReadS [CreateSubnetGroup]
(Int -> ReadS CreateSubnetGroup)
-> ReadS [CreateSubnetGroup]
-> ReadPrec CreateSubnetGroup
-> ReadPrec [CreateSubnetGroup]
-> Read CreateSubnetGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSubnetGroup]
$creadListPrec :: ReadPrec [CreateSubnetGroup]
readPrec :: ReadPrec CreateSubnetGroup
$creadPrec :: ReadPrec CreateSubnetGroup
readList :: ReadS [CreateSubnetGroup]
$creadList :: ReadS [CreateSubnetGroup]
readsPrec :: Int -> ReadS CreateSubnetGroup
$creadsPrec :: Int -> ReadS CreateSubnetGroup
Prelude.Read, Int -> CreateSubnetGroup -> ShowS
[CreateSubnetGroup] -> ShowS
CreateSubnetGroup -> String
(Int -> CreateSubnetGroup -> ShowS)
-> (CreateSubnetGroup -> String)
-> ([CreateSubnetGroup] -> ShowS)
-> Show CreateSubnetGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSubnetGroup] -> ShowS
$cshowList :: [CreateSubnetGroup] -> ShowS
show :: CreateSubnetGroup -> String
$cshow :: CreateSubnetGroup -> String
showsPrec :: Int -> CreateSubnetGroup -> ShowS
$cshowsPrec :: Int -> CreateSubnetGroup -> ShowS
Prelude.Show, (forall x. CreateSubnetGroup -> Rep CreateSubnetGroup x)
-> (forall x. Rep CreateSubnetGroup x -> CreateSubnetGroup)
-> Generic CreateSubnetGroup
forall x. Rep CreateSubnetGroup x -> CreateSubnetGroup
forall x. CreateSubnetGroup -> Rep CreateSubnetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSubnetGroup x -> CreateSubnetGroup
$cfrom :: forall x. CreateSubnetGroup -> Rep CreateSubnetGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateSubnetGroup' 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', 'createSubnetGroup_description' - A description for the subnet group
--
-- 'subnetGroupName', 'createSubnetGroup_subnetGroupName' - A name for the subnet group. This value is stored as a lowercase string.
--
-- 'subnetIds', 'createSubnetGroup_subnetIds' - A list of VPC subnet IDs for the subnet group.
newCreateSubnetGroup ::
  -- | 'subnetGroupName'
  Prelude.Text ->
  CreateSubnetGroup
newCreateSubnetGroup :: Text -> CreateSubnetGroup
newCreateSubnetGroup Text
pSubnetGroupName_ =
  CreateSubnetGroup' :: Maybe Text -> Text -> [Text] -> CreateSubnetGroup
CreateSubnetGroup'
    { $sel:description:CreateSubnetGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetGroupName:CreateSubnetGroup' :: Text
subnetGroupName = Text
pSubnetGroupName_,
      $sel:subnetIds:CreateSubnetGroup' :: [Text]
subnetIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A description for the subnet group
createSubnetGroup_description :: Lens.Lens' CreateSubnetGroup (Prelude.Maybe Prelude.Text)
createSubnetGroup_description :: (Maybe Text -> f (Maybe Text))
-> CreateSubnetGroup -> f CreateSubnetGroup
createSubnetGroup_description = (CreateSubnetGroup -> Maybe Text)
-> (CreateSubnetGroup -> Maybe Text -> CreateSubnetGroup)
-> Lens
     CreateSubnetGroup CreateSubnetGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSubnetGroup' {Maybe Text
description :: Maybe Text
$sel:description:CreateSubnetGroup' :: CreateSubnetGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateSubnetGroup
s@CreateSubnetGroup' {} Maybe Text
a -> CreateSubnetGroup
s {$sel:description:CreateSubnetGroup' :: Maybe Text
description = Maybe Text
a} :: CreateSubnetGroup)

-- | A name for the subnet group. This value is stored as a lowercase string.
createSubnetGroup_subnetGroupName :: Lens.Lens' CreateSubnetGroup Prelude.Text
createSubnetGroup_subnetGroupName :: (Text -> f Text) -> CreateSubnetGroup -> f CreateSubnetGroup
createSubnetGroup_subnetGroupName = (CreateSubnetGroup -> Text)
-> (CreateSubnetGroup -> Text -> CreateSubnetGroup)
-> Lens CreateSubnetGroup CreateSubnetGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSubnetGroup' {Text
subnetGroupName :: Text
$sel:subnetGroupName:CreateSubnetGroup' :: CreateSubnetGroup -> Text
subnetGroupName} -> Text
subnetGroupName) (\s :: CreateSubnetGroup
s@CreateSubnetGroup' {} Text
a -> CreateSubnetGroup
s {$sel:subnetGroupName:CreateSubnetGroup' :: Text
subnetGroupName = Text
a} :: CreateSubnetGroup)

-- | A list of VPC subnet IDs for the subnet group.
createSubnetGroup_subnetIds :: Lens.Lens' CreateSubnetGroup [Prelude.Text]
createSubnetGroup_subnetIds :: ([Text] -> f [Text]) -> CreateSubnetGroup -> f CreateSubnetGroup
createSubnetGroup_subnetIds = (CreateSubnetGroup -> [Text])
-> (CreateSubnetGroup -> [Text] -> CreateSubnetGroup)
-> Lens CreateSubnetGroup CreateSubnetGroup [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSubnetGroup' {[Text]
subnetIds :: [Text]
$sel:subnetIds:CreateSubnetGroup' :: CreateSubnetGroup -> [Text]
subnetIds} -> [Text]
subnetIds) (\s :: CreateSubnetGroup
s@CreateSubnetGroup' {} [Text]
a -> CreateSubnetGroup
s {$sel:subnetIds:CreateSubnetGroup' :: [Text]
subnetIds = [Text]
a} :: CreateSubnetGroup) (([Text] -> f [Text]) -> CreateSubnetGroup -> f CreateSubnetGroup)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateSubnetGroup
-> f CreateSubnetGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateSubnetGroup where
  type
    AWSResponse CreateSubnetGroup =
      CreateSubnetGroupResponse
  request :: CreateSubnetGroup -> Request CreateSubnetGroup
request = Service -> CreateSubnetGroup -> Request CreateSubnetGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateSubnetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSubnetGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateSubnetGroup))
-> Logger
-> Service
-> Proxy CreateSubnetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSubnetGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe SubnetGroup -> Int -> CreateSubnetGroupResponse
CreateSubnetGroupResponse'
            (Maybe SubnetGroup -> Int -> CreateSubnetGroupResponse)
-> Either String (Maybe SubnetGroup)
-> Either String (Int -> CreateSubnetGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SubnetGroup)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SubnetGroup")
            Either String (Int -> CreateSubnetGroupResponse)
-> Either String Int -> Either String CreateSubnetGroupResponse
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 CreateSubnetGroup

instance Prelude.NFData CreateSubnetGroup

instance Core.ToHeaders CreateSubnetGroup where
  toHeaders :: CreateSubnetGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateSubnetGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonDAXV3.CreateSubnetGroup" ::
                          Prelude.ByteString
                      ),
            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 CreateSubnetGroup where
  toJSON :: CreateSubnetGroup -> Value
toJSON CreateSubnetGroup' {[Text]
Maybe Text
Text
subnetIds :: [Text]
subnetGroupName :: Text
description :: Maybe Text
$sel:subnetIds:CreateSubnetGroup' :: CreateSubnetGroup -> [Text]
$sel:subnetGroupName:CreateSubnetGroup' :: CreateSubnetGroup -> Text
$sel:description:CreateSubnetGroup' :: CreateSubnetGroup -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Description" 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
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SubnetGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
subnetGroupName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SubnetIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
subnetIds)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateSubnetGroupResponse' 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:
--
-- 'subnetGroup', 'createSubnetGroupResponse_subnetGroup' - Represents the output of a /CreateSubnetGroup/ operation.
--
-- 'httpStatus', 'createSubnetGroupResponse_httpStatus' - The response's http status code.
newCreateSubnetGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateSubnetGroupResponse
newCreateSubnetGroupResponse :: Int -> CreateSubnetGroupResponse
newCreateSubnetGroupResponse Int
pHttpStatus_ =
  CreateSubnetGroupResponse' :: Maybe SubnetGroup -> Int -> CreateSubnetGroupResponse
CreateSubnetGroupResponse'
    { $sel:subnetGroup:CreateSubnetGroupResponse' :: Maybe SubnetGroup
subnetGroup =
        Maybe SubnetGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateSubnetGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Represents the output of a /CreateSubnetGroup/ operation.
createSubnetGroupResponse_subnetGroup :: Lens.Lens' CreateSubnetGroupResponse (Prelude.Maybe SubnetGroup)
createSubnetGroupResponse_subnetGroup :: (Maybe SubnetGroup -> f (Maybe SubnetGroup))
-> CreateSubnetGroupResponse -> f CreateSubnetGroupResponse
createSubnetGroupResponse_subnetGroup = (CreateSubnetGroupResponse -> Maybe SubnetGroup)
-> (CreateSubnetGroupResponse
    -> Maybe SubnetGroup -> CreateSubnetGroupResponse)
-> Lens
     CreateSubnetGroupResponse
     CreateSubnetGroupResponse
     (Maybe SubnetGroup)
     (Maybe SubnetGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSubnetGroupResponse' {Maybe SubnetGroup
subnetGroup :: Maybe SubnetGroup
$sel:subnetGroup:CreateSubnetGroupResponse' :: CreateSubnetGroupResponse -> Maybe SubnetGroup
subnetGroup} -> Maybe SubnetGroup
subnetGroup) (\s :: CreateSubnetGroupResponse
s@CreateSubnetGroupResponse' {} Maybe SubnetGroup
a -> CreateSubnetGroupResponse
s {$sel:subnetGroup:CreateSubnetGroupResponse' :: Maybe SubnetGroup
subnetGroup = Maybe SubnetGroup
a} :: CreateSubnetGroupResponse)

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

instance Prelude.NFData CreateSubnetGroupResponse