{-# 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.Route53Resolver.CreateResolverEndpoint
-- 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 Resolver endpoint. There are two types of Resolver endpoints,
-- inbound and outbound:
--
-- -   An /inbound Resolver endpoint/ forwards DNS queries to the DNS
--     service for a VPC from your network.
--
-- -   An /outbound Resolver endpoint/ forwards DNS queries from the DNS
--     service for a VPC to your network.
module Amazonka.Route53Resolver.CreateResolverEndpoint
  ( -- * Creating a Request
    CreateResolverEndpoint (..),
    newCreateResolverEndpoint,

    -- * Request Lenses
    createResolverEndpoint_name,
    createResolverEndpoint_tags,
    createResolverEndpoint_creatorRequestId,
    createResolverEndpoint_securityGroupIds,
    createResolverEndpoint_direction,
    createResolverEndpoint_ipAddresses,

    -- * Destructuring the Response
    CreateResolverEndpointResponse (..),
    newCreateResolverEndpointResponse,

    -- * Response Lenses
    createResolverEndpointResponse_resolverEndpoint,
    createResolverEndpointResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateResolverEndpoint' smart constructor.
data CreateResolverEndpoint = CreateResolverEndpoint'
  { -- | A friendly name that lets you easily find a configuration in the
    -- Resolver dashboard in the Route 53 console.
    CreateResolverEndpoint -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A list of the tag keys and values that you want to associate with the
    -- endpoint.
    CreateResolverEndpoint -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | A unique string that identifies the request and that allows failed
    -- requests to be retried without the risk of running the operation twice.
    -- @CreatorRequestId@ can be any unique string, for example, a date\/time
    -- stamp.
    CreateResolverEndpoint -> Text
creatorRequestId :: Prelude.Text,
    -- | The ID of one or more security groups that you want to use to control
    -- access to this VPC. The security group that you specify must include one
    -- or more inbound rules (for inbound Resolver endpoints) or outbound rules
    -- (for outbound Resolver endpoints). Inbound and outbound rules must allow
    -- TCP and UDP access. For inbound access, open port 53. For outbound
    -- access, open the port that you\'re using for DNS queries on your
    -- network.
    CreateResolverEndpoint -> [Text]
securityGroupIds :: [Prelude.Text],
    -- | Specify the applicable value:
    --
    -- -   @INBOUND@: Resolver forwards DNS queries to the DNS service for a
    --     VPC from your network
    --
    -- -   @OUTBOUND@: Resolver forwards DNS queries from the DNS service for a
    --     VPC to your network
    CreateResolverEndpoint -> ResolverEndpointDirection
direction :: ResolverEndpointDirection,
    -- | The subnets and IP addresses in your VPC that DNS queries originate from
    -- (for outbound endpoints) or that you forward DNS queries to (for inbound
    -- endpoints). The subnet ID uniquely identifies a VPC.
    CreateResolverEndpoint -> NonEmpty IpAddressRequest
ipAddresses :: Prelude.NonEmpty IpAddressRequest
  }
  deriving (CreateResolverEndpoint -> CreateResolverEndpoint -> Bool
(CreateResolverEndpoint -> CreateResolverEndpoint -> Bool)
-> (CreateResolverEndpoint -> CreateResolverEndpoint -> Bool)
-> Eq CreateResolverEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResolverEndpoint -> CreateResolverEndpoint -> Bool
$c/= :: CreateResolverEndpoint -> CreateResolverEndpoint -> Bool
== :: CreateResolverEndpoint -> CreateResolverEndpoint -> Bool
$c== :: CreateResolverEndpoint -> CreateResolverEndpoint -> Bool
Prelude.Eq, ReadPrec [CreateResolverEndpoint]
ReadPrec CreateResolverEndpoint
Int -> ReadS CreateResolverEndpoint
ReadS [CreateResolverEndpoint]
(Int -> ReadS CreateResolverEndpoint)
-> ReadS [CreateResolverEndpoint]
-> ReadPrec CreateResolverEndpoint
-> ReadPrec [CreateResolverEndpoint]
-> Read CreateResolverEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResolverEndpoint]
$creadListPrec :: ReadPrec [CreateResolverEndpoint]
readPrec :: ReadPrec CreateResolverEndpoint
$creadPrec :: ReadPrec CreateResolverEndpoint
readList :: ReadS [CreateResolverEndpoint]
$creadList :: ReadS [CreateResolverEndpoint]
readsPrec :: Int -> ReadS CreateResolverEndpoint
$creadsPrec :: Int -> ReadS CreateResolverEndpoint
Prelude.Read, Int -> CreateResolverEndpoint -> ShowS
[CreateResolverEndpoint] -> ShowS
CreateResolverEndpoint -> String
(Int -> CreateResolverEndpoint -> ShowS)
-> (CreateResolverEndpoint -> String)
-> ([CreateResolverEndpoint] -> ShowS)
-> Show CreateResolverEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResolverEndpoint] -> ShowS
$cshowList :: [CreateResolverEndpoint] -> ShowS
show :: CreateResolverEndpoint -> String
$cshow :: CreateResolverEndpoint -> String
showsPrec :: Int -> CreateResolverEndpoint -> ShowS
$cshowsPrec :: Int -> CreateResolverEndpoint -> ShowS
Prelude.Show, (forall x. CreateResolverEndpoint -> Rep CreateResolverEndpoint x)
-> (forall x.
    Rep CreateResolverEndpoint x -> CreateResolverEndpoint)
-> Generic CreateResolverEndpoint
forall x. Rep CreateResolverEndpoint x -> CreateResolverEndpoint
forall x. CreateResolverEndpoint -> Rep CreateResolverEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResolverEndpoint x -> CreateResolverEndpoint
$cfrom :: forall x. CreateResolverEndpoint -> Rep CreateResolverEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'CreateResolverEndpoint' 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', 'createResolverEndpoint_name' - A friendly name that lets you easily find a configuration in the
-- Resolver dashboard in the Route 53 console.
--
-- 'tags', 'createResolverEndpoint_tags' - A list of the tag keys and values that you want to associate with the
-- endpoint.
--
-- 'creatorRequestId', 'createResolverEndpoint_creatorRequestId' - A unique string that identifies the request and that allows failed
-- requests to be retried without the risk of running the operation twice.
-- @CreatorRequestId@ can be any unique string, for example, a date\/time
-- stamp.
--
-- 'securityGroupIds', 'createResolverEndpoint_securityGroupIds' - The ID of one or more security groups that you want to use to control
-- access to this VPC. The security group that you specify must include one
-- or more inbound rules (for inbound Resolver endpoints) or outbound rules
-- (for outbound Resolver endpoints). Inbound and outbound rules must allow
-- TCP and UDP access. For inbound access, open port 53. For outbound
-- access, open the port that you\'re using for DNS queries on your
-- network.
--
-- 'direction', 'createResolverEndpoint_direction' - Specify the applicable value:
--
-- -   @INBOUND@: Resolver forwards DNS queries to the DNS service for a
--     VPC from your network
--
-- -   @OUTBOUND@: Resolver forwards DNS queries from the DNS service for a
--     VPC to your network
--
-- 'ipAddresses', 'createResolverEndpoint_ipAddresses' - The subnets and IP addresses in your VPC that DNS queries originate from
-- (for outbound endpoints) or that you forward DNS queries to (for inbound
-- endpoints). The subnet ID uniquely identifies a VPC.
newCreateResolverEndpoint ::
  -- | 'creatorRequestId'
  Prelude.Text ->
  -- | 'direction'
  ResolverEndpointDirection ->
  -- | 'ipAddresses'
  Prelude.NonEmpty IpAddressRequest ->
  CreateResolverEndpoint
newCreateResolverEndpoint :: Text
-> ResolverEndpointDirection
-> NonEmpty IpAddressRequest
-> CreateResolverEndpoint
newCreateResolverEndpoint
  Text
pCreatorRequestId_
  ResolverEndpointDirection
pDirection_
  NonEmpty IpAddressRequest
pIpAddresses_ =
    CreateResolverEndpoint' :: Maybe Text
-> Maybe [Tag]
-> Text
-> [Text]
-> ResolverEndpointDirection
-> NonEmpty IpAddressRequest
-> CreateResolverEndpoint
CreateResolverEndpoint'
      { $sel:name:CreateResolverEndpoint' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateResolverEndpoint' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:creatorRequestId:CreateResolverEndpoint' :: Text
creatorRequestId = Text
pCreatorRequestId_,
        $sel:securityGroupIds:CreateResolverEndpoint' :: [Text]
securityGroupIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:direction:CreateResolverEndpoint' :: ResolverEndpointDirection
direction = ResolverEndpointDirection
pDirection_,
        $sel:ipAddresses:CreateResolverEndpoint' :: NonEmpty IpAddressRequest
ipAddresses = Tagged
  (NonEmpty IpAddressRequest) (Identity (NonEmpty IpAddressRequest))
-> Tagged
     (NonEmpty IpAddressRequest) (Identity (NonEmpty IpAddressRequest))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty IpAddressRequest) (Identity (NonEmpty IpAddressRequest))
 -> Tagged
      (NonEmpty IpAddressRequest) (Identity (NonEmpty IpAddressRequest)))
-> NonEmpty IpAddressRequest -> NonEmpty IpAddressRequest
forall t b. AReview t b -> b -> t
Lens.# NonEmpty IpAddressRequest
pIpAddresses_
      }

-- | A friendly name that lets you easily find a configuration in the
-- Resolver dashboard in the Route 53 console.
createResolverEndpoint_name :: Lens.Lens' CreateResolverEndpoint (Prelude.Maybe Prelude.Text)
createResolverEndpoint_name :: (Maybe Text -> f (Maybe Text))
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_name = (CreateResolverEndpoint -> Maybe Text)
-> (CreateResolverEndpoint -> Maybe Text -> CreateResolverEndpoint)
-> Lens
     CreateResolverEndpoint
     CreateResolverEndpoint
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {Maybe Text
name :: Maybe Text
$sel:name:CreateResolverEndpoint' :: CreateResolverEndpoint -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} Maybe Text
a -> CreateResolverEndpoint
s {$sel:name:CreateResolverEndpoint' :: Maybe Text
name = Maybe Text
a} :: CreateResolverEndpoint)

-- | A list of the tag keys and values that you want to associate with the
-- endpoint.
createResolverEndpoint_tags :: Lens.Lens' CreateResolverEndpoint (Prelude.Maybe [Tag])
createResolverEndpoint_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_tags = (CreateResolverEndpoint -> Maybe [Tag])
-> (CreateResolverEndpoint
    -> Maybe [Tag] -> CreateResolverEndpoint)
-> Lens
     CreateResolverEndpoint
     CreateResolverEndpoint
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateResolverEndpoint' :: CreateResolverEndpoint -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} Maybe [Tag]
a -> CreateResolverEndpoint
s {$sel:tags:CreateResolverEndpoint' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateResolverEndpoint) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateResolverEndpoint -> f CreateResolverEndpoint)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateResolverEndpoint
-> f CreateResolverEndpoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique string that identifies the request and that allows failed
-- requests to be retried without the risk of running the operation twice.
-- @CreatorRequestId@ can be any unique string, for example, a date\/time
-- stamp.
createResolverEndpoint_creatorRequestId :: Lens.Lens' CreateResolverEndpoint Prelude.Text
createResolverEndpoint_creatorRequestId :: (Text -> f Text)
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_creatorRequestId = (CreateResolverEndpoint -> Text)
-> (CreateResolverEndpoint -> Text -> CreateResolverEndpoint)
-> Lens CreateResolverEndpoint CreateResolverEndpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {Text
creatorRequestId :: Text
$sel:creatorRequestId:CreateResolverEndpoint' :: CreateResolverEndpoint -> Text
creatorRequestId} -> Text
creatorRequestId) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} Text
a -> CreateResolverEndpoint
s {$sel:creatorRequestId:CreateResolverEndpoint' :: Text
creatorRequestId = Text
a} :: CreateResolverEndpoint)

-- | The ID of one or more security groups that you want to use to control
-- access to this VPC. The security group that you specify must include one
-- or more inbound rules (for inbound Resolver endpoints) or outbound rules
-- (for outbound Resolver endpoints). Inbound and outbound rules must allow
-- TCP and UDP access. For inbound access, open port 53. For outbound
-- access, open the port that you\'re using for DNS queries on your
-- network.
createResolverEndpoint_securityGroupIds :: Lens.Lens' CreateResolverEndpoint [Prelude.Text]
createResolverEndpoint_securityGroupIds :: ([Text] -> f [Text])
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_securityGroupIds = (CreateResolverEndpoint -> [Text])
-> (CreateResolverEndpoint -> [Text] -> CreateResolverEndpoint)
-> Lens CreateResolverEndpoint CreateResolverEndpoint [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {[Text]
securityGroupIds :: [Text]
$sel:securityGroupIds:CreateResolverEndpoint' :: CreateResolverEndpoint -> [Text]
securityGroupIds} -> [Text]
securityGroupIds) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} [Text]
a -> CreateResolverEndpoint
s {$sel:securityGroupIds:CreateResolverEndpoint' :: [Text]
securityGroupIds = [Text]
a} :: CreateResolverEndpoint) (([Text] -> f [Text])
 -> CreateResolverEndpoint -> f CreateResolverEndpoint)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateResolverEndpoint
-> f CreateResolverEndpoint
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

-- | Specify the applicable value:
--
-- -   @INBOUND@: Resolver forwards DNS queries to the DNS service for a
--     VPC from your network
--
-- -   @OUTBOUND@: Resolver forwards DNS queries from the DNS service for a
--     VPC to your network
createResolverEndpoint_direction :: Lens.Lens' CreateResolverEndpoint ResolverEndpointDirection
createResolverEndpoint_direction :: (ResolverEndpointDirection -> f ResolverEndpointDirection)
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_direction = (CreateResolverEndpoint -> ResolverEndpointDirection)
-> (CreateResolverEndpoint
    -> ResolverEndpointDirection -> CreateResolverEndpoint)
-> Lens
     CreateResolverEndpoint
     CreateResolverEndpoint
     ResolverEndpointDirection
     ResolverEndpointDirection
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {ResolverEndpointDirection
direction :: ResolverEndpointDirection
$sel:direction:CreateResolverEndpoint' :: CreateResolverEndpoint -> ResolverEndpointDirection
direction} -> ResolverEndpointDirection
direction) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} ResolverEndpointDirection
a -> CreateResolverEndpoint
s {$sel:direction:CreateResolverEndpoint' :: ResolverEndpointDirection
direction = ResolverEndpointDirection
a} :: CreateResolverEndpoint)

-- | The subnets and IP addresses in your VPC that DNS queries originate from
-- (for outbound endpoints) or that you forward DNS queries to (for inbound
-- endpoints). The subnet ID uniquely identifies a VPC.
createResolverEndpoint_ipAddresses :: Lens.Lens' CreateResolverEndpoint (Prelude.NonEmpty IpAddressRequest)
createResolverEndpoint_ipAddresses :: (NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
-> CreateResolverEndpoint -> f CreateResolverEndpoint
createResolverEndpoint_ipAddresses = (CreateResolverEndpoint -> NonEmpty IpAddressRequest)
-> (CreateResolverEndpoint
    -> NonEmpty IpAddressRequest -> CreateResolverEndpoint)
-> Lens
     CreateResolverEndpoint
     CreateResolverEndpoint
     (NonEmpty IpAddressRequest)
     (NonEmpty IpAddressRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpoint' {NonEmpty IpAddressRequest
ipAddresses :: NonEmpty IpAddressRequest
$sel:ipAddresses:CreateResolverEndpoint' :: CreateResolverEndpoint -> NonEmpty IpAddressRequest
ipAddresses} -> NonEmpty IpAddressRequest
ipAddresses) (\s :: CreateResolverEndpoint
s@CreateResolverEndpoint' {} NonEmpty IpAddressRequest
a -> CreateResolverEndpoint
s {$sel:ipAddresses:CreateResolverEndpoint' :: NonEmpty IpAddressRequest
ipAddresses = NonEmpty IpAddressRequest
a} :: CreateResolverEndpoint) ((NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
 -> CreateResolverEndpoint -> f CreateResolverEndpoint)
-> ((NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
    -> NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
-> (NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
-> CreateResolverEndpoint
-> f CreateResolverEndpoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest))
-> NonEmpty IpAddressRequest -> f (NonEmpty IpAddressRequest)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData CreateResolverEndpoint

instance Core.ToHeaders CreateResolverEndpoint where
  toHeaders :: CreateResolverEndpoint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateResolverEndpoint -> 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
"Route53Resolver.CreateResolverEndpoint" ::
                          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 CreateResolverEndpoint where
  toJSON :: CreateResolverEndpoint -> Value
toJSON CreateResolverEndpoint' {[Text]
Maybe [Tag]
Maybe Text
NonEmpty IpAddressRequest
Text
ResolverEndpointDirection
ipAddresses :: NonEmpty IpAddressRequest
direction :: ResolverEndpointDirection
securityGroupIds :: [Text]
creatorRequestId :: Text
tags :: Maybe [Tag]
name :: Maybe Text
$sel:ipAddresses:CreateResolverEndpoint' :: CreateResolverEndpoint -> NonEmpty IpAddressRequest
$sel:direction:CreateResolverEndpoint' :: CreateResolverEndpoint -> ResolverEndpointDirection
$sel:securityGroupIds:CreateResolverEndpoint' :: CreateResolverEndpoint -> [Text]
$sel:creatorRequestId:CreateResolverEndpoint' :: CreateResolverEndpoint -> Text
$sel:tags:CreateResolverEndpoint' :: CreateResolverEndpoint -> Maybe [Tag]
$sel:name:CreateResolverEndpoint' :: CreateResolverEndpoint -> 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,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CreatorRequestId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
creatorRequestId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SecurityGroupIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
securityGroupIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Direction" Text -> ResolverEndpointDirection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResolverEndpointDirection
direction),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IpAddresses" Text -> NonEmpty IpAddressRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty IpAddressRequest
ipAddresses)
          ]
      )

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

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

-- | /See:/ 'newCreateResolverEndpointResponse' smart constructor.
data CreateResolverEndpointResponse = CreateResolverEndpointResponse'
  { -- | Information about the @CreateResolverEndpoint@ request, including the
    -- status of the request.
    CreateResolverEndpointResponse -> Maybe ResolverEndpoint
resolverEndpoint :: Prelude.Maybe ResolverEndpoint,
    -- | The response's http status code.
    CreateResolverEndpointResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateResolverEndpointResponse
-> CreateResolverEndpointResponse -> Bool
(CreateResolverEndpointResponse
 -> CreateResolverEndpointResponse -> Bool)
-> (CreateResolverEndpointResponse
    -> CreateResolverEndpointResponse -> Bool)
-> Eq CreateResolverEndpointResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResolverEndpointResponse
-> CreateResolverEndpointResponse -> Bool
$c/= :: CreateResolverEndpointResponse
-> CreateResolverEndpointResponse -> Bool
== :: CreateResolverEndpointResponse
-> CreateResolverEndpointResponse -> Bool
$c== :: CreateResolverEndpointResponse
-> CreateResolverEndpointResponse -> Bool
Prelude.Eq, ReadPrec [CreateResolverEndpointResponse]
ReadPrec CreateResolverEndpointResponse
Int -> ReadS CreateResolverEndpointResponse
ReadS [CreateResolverEndpointResponse]
(Int -> ReadS CreateResolverEndpointResponse)
-> ReadS [CreateResolverEndpointResponse]
-> ReadPrec CreateResolverEndpointResponse
-> ReadPrec [CreateResolverEndpointResponse]
-> Read CreateResolverEndpointResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateResolverEndpointResponse]
$creadListPrec :: ReadPrec [CreateResolverEndpointResponse]
readPrec :: ReadPrec CreateResolverEndpointResponse
$creadPrec :: ReadPrec CreateResolverEndpointResponse
readList :: ReadS [CreateResolverEndpointResponse]
$creadList :: ReadS [CreateResolverEndpointResponse]
readsPrec :: Int -> ReadS CreateResolverEndpointResponse
$creadsPrec :: Int -> ReadS CreateResolverEndpointResponse
Prelude.Read, Int -> CreateResolverEndpointResponse -> ShowS
[CreateResolverEndpointResponse] -> ShowS
CreateResolverEndpointResponse -> String
(Int -> CreateResolverEndpointResponse -> ShowS)
-> (CreateResolverEndpointResponse -> String)
-> ([CreateResolverEndpointResponse] -> ShowS)
-> Show CreateResolverEndpointResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResolverEndpointResponse] -> ShowS
$cshowList :: [CreateResolverEndpointResponse] -> ShowS
show :: CreateResolverEndpointResponse -> String
$cshow :: CreateResolverEndpointResponse -> String
showsPrec :: Int -> CreateResolverEndpointResponse -> ShowS
$cshowsPrec :: Int -> CreateResolverEndpointResponse -> ShowS
Prelude.Show, (forall x.
 CreateResolverEndpointResponse
 -> Rep CreateResolverEndpointResponse x)
-> (forall x.
    Rep CreateResolverEndpointResponse x
    -> CreateResolverEndpointResponse)
-> Generic CreateResolverEndpointResponse
forall x.
Rep CreateResolverEndpointResponse x
-> CreateResolverEndpointResponse
forall x.
CreateResolverEndpointResponse
-> Rep CreateResolverEndpointResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateResolverEndpointResponse x
-> CreateResolverEndpointResponse
$cfrom :: forall x.
CreateResolverEndpointResponse
-> Rep CreateResolverEndpointResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateResolverEndpointResponse' 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:
--
-- 'resolverEndpoint', 'createResolverEndpointResponse_resolverEndpoint' - Information about the @CreateResolverEndpoint@ request, including the
-- status of the request.
--
-- 'httpStatus', 'createResolverEndpointResponse_httpStatus' - The response's http status code.
newCreateResolverEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateResolverEndpointResponse
newCreateResolverEndpointResponse :: Int -> CreateResolverEndpointResponse
newCreateResolverEndpointResponse Int
pHttpStatus_ =
  CreateResolverEndpointResponse' :: Maybe ResolverEndpoint -> Int -> CreateResolverEndpointResponse
CreateResolverEndpointResponse'
    { $sel:resolverEndpoint:CreateResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint =
        Maybe ResolverEndpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateResolverEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the @CreateResolverEndpoint@ request, including the
-- status of the request.
createResolverEndpointResponse_resolverEndpoint :: Lens.Lens' CreateResolverEndpointResponse (Prelude.Maybe ResolverEndpoint)
createResolverEndpointResponse_resolverEndpoint :: (Maybe ResolverEndpoint -> f (Maybe ResolverEndpoint))
-> CreateResolverEndpointResponse
-> f CreateResolverEndpointResponse
createResolverEndpointResponse_resolverEndpoint = (CreateResolverEndpointResponse -> Maybe ResolverEndpoint)
-> (CreateResolverEndpointResponse
    -> Maybe ResolverEndpoint -> CreateResolverEndpointResponse)
-> Lens
     CreateResolverEndpointResponse
     CreateResolverEndpointResponse
     (Maybe ResolverEndpoint)
     (Maybe ResolverEndpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResolverEndpointResponse' {Maybe ResolverEndpoint
resolverEndpoint :: Maybe ResolverEndpoint
$sel:resolverEndpoint:CreateResolverEndpointResponse' :: CreateResolverEndpointResponse -> Maybe ResolverEndpoint
resolverEndpoint} -> Maybe ResolverEndpoint
resolverEndpoint) (\s :: CreateResolverEndpointResponse
s@CreateResolverEndpointResponse' {} Maybe ResolverEndpoint
a -> CreateResolverEndpointResponse
s {$sel:resolverEndpoint:CreateResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint = Maybe ResolverEndpoint
a} :: CreateResolverEndpointResponse)

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

instance
  Prelude.NFData
    CreateResolverEndpointResponse