{-# 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.RedshiftServerLess.UpdateEndpointAccess
-- 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 an Amazon Redshift Serverless managed endpoint.
module Amazonka.RedshiftServerLess.UpdateEndpointAccess
  ( -- * Creating a Request
    UpdateEndpointAccess (..),
    newUpdateEndpointAccess,

    -- * Request Lenses
    updateEndpointAccess_vpcSecurityGroupIds,
    updateEndpointAccess_endpointName,

    -- * Destructuring the Response
    UpdateEndpointAccessResponse (..),
    newUpdateEndpointAccessResponse,

    -- * Response Lenses
    updateEndpointAccessResponse_endpoint,
    updateEndpointAccessResponse_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.RedshiftServerLess.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateEndpointAccess' smart constructor.
data UpdateEndpointAccess = UpdateEndpointAccess'
  { -- | The list of VPC security groups associated with the endpoint after the
    -- endpoint is modified.
    UpdateEndpointAccess -> Maybe [Text]
vpcSecurityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The name of the VPC endpoint to update.
    UpdateEndpointAccess -> Text
endpointName :: Prelude.Text
  }
  deriving (UpdateEndpointAccess -> UpdateEndpointAccess -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEndpointAccess -> UpdateEndpointAccess -> Bool
$c/= :: UpdateEndpointAccess -> UpdateEndpointAccess -> Bool
== :: UpdateEndpointAccess -> UpdateEndpointAccess -> Bool
$c== :: UpdateEndpointAccess -> UpdateEndpointAccess -> Bool
Prelude.Eq, ReadPrec [UpdateEndpointAccess]
ReadPrec UpdateEndpointAccess
Int -> ReadS UpdateEndpointAccess
ReadS [UpdateEndpointAccess]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEndpointAccess]
$creadListPrec :: ReadPrec [UpdateEndpointAccess]
readPrec :: ReadPrec UpdateEndpointAccess
$creadPrec :: ReadPrec UpdateEndpointAccess
readList :: ReadS [UpdateEndpointAccess]
$creadList :: ReadS [UpdateEndpointAccess]
readsPrec :: Int -> ReadS UpdateEndpointAccess
$creadsPrec :: Int -> ReadS UpdateEndpointAccess
Prelude.Read, Int -> UpdateEndpointAccess -> ShowS
[UpdateEndpointAccess] -> ShowS
UpdateEndpointAccess -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEndpointAccess] -> ShowS
$cshowList :: [UpdateEndpointAccess] -> ShowS
show :: UpdateEndpointAccess -> String
$cshow :: UpdateEndpointAccess -> String
showsPrec :: Int -> UpdateEndpointAccess -> ShowS
$cshowsPrec :: Int -> UpdateEndpointAccess -> ShowS
Prelude.Show, forall x. Rep UpdateEndpointAccess x -> UpdateEndpointAccess
forall x. UpdateEndpointAccess -> Rep UpdateEndpointAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateEndpointAccess x -> UpdateEndpointAccess
$cfrom :: forall x. UpdateEndpointAccess -> Rep UpdateEndpointAccess x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEndpointAccess' 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:
--
-- 'vpcSecurityGroupIds', 'updateEndpointAccess_vpcSecurityGroupIds' - The list of VPC security groups associated with the endpoint after the
-- endpoint is modified.
--
-- 'endpointName', 'updateEndpointAccess_endpointName' - The name of the VPC endpoint to update.
newUpdateEndpointAccess ::
  -- | 'endpointName'
  Prelude.Text ->
  UpdateEndpointAccess
newUpdateEndpointAccess :: Text -> UpdateEndpointAccess
newUpdateEndpointAccess Text
pEndpointName_ =
  UpdateEndpointAccess'
    { $sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: Maybe [Text]
vpcSecurityGroupIds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endpointName:UpdateEndpointAccess' :: Text
endpointName = Text
pEndpointName_
    }

-- | The list of VPC security groups associated with the endpoint after the
-- endpoint is modified.
updateEndpointAccess_vpcSecurityGroupIds :: Lens.Lens' UpdateEndpointAccess (Prelude.Maybe [Prelude.Text])
updateEndpointAccess_vpcSecurityGroupIds :: Lens' UpdateEndpointAccess (Maybe [Text])
updateEndpointAccess_vpcSecurityGroupIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointAccess' {Maybe [Text]
vpcSecurityGroupIds :: Maybe [Text]
$sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: UpdateEndpointAccess -> Maybe [Text]
vpcSecurityGroupIds} -> Maybe [Text]
vpcSecurityGroupIds) (\s :: UpdateEndpointAccess
s@UpdateEndpointAccess' {} Maybe [Text]
a -> UpdateEndpointAccess
s {$sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: Maybe [Text]
vpcSecurityGroupIds = Maybe [Text]
a} :: UpdateEndpointAccess) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the VPC endpoint to update.
updateEndpointAccess_endpointName :: Lens.Lens' UpdateEndpointAccess Prelude.Text
updateEndpointAccess_endpointName :: Lens' UpdateEndpointAccess Text
updateEndpointAccess_endpointName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointAccess' {Text
endpointName :: Text
$sel:endpointName:UpdateEndpointAccess' :: UpdateEndpointAccess -> Text
endpointName} -> Text
endpointName) (\s :: UpdateEndpointAccess
s@UpdateEndpointAccess' {} Text
a -> UpdateEndpointAccess
s {$sel:endpointName:UpdateEndpointAccess' :: Text
endpointName = Text
a} :: UpdateEndpointAccess)

instance Core.AWSRequest UpdateEndpointAccess where
  type
    AWSResponse UpdateEndpointAccess =
      UpdateEndpointAccessResponse
  request :: (Service -> Service)
-> UpdateEndpointAccess -> Request UpdateEndpointAccess
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 UpdateEndpointAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEndpointAccess)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe EndpointAccess -> Int -> UpdateEndpointAccessResponse
UpdateEndpointAccessResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"endpoint")
            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 UpdateEndpointAccess where
  hashWithSalt :: Int -> UpdateEndpointAccess -> Int
hashWithSalt Int
_salt UpdateEndpointAccess' {Maybe [Text]
Text
endpointName :: Text
vpcSecurityGroupIds :: Maybe [Text]
$sel:endpointName:UpdateEndpointAccess' :: UpdateEndpointAccess -> Text
$sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: UpdateEndpointAccess -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
vpcSecurityGroupIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointName

instance Prelude.NFData UpdateEndpointAccess where
  rnf :: UpdateEndpointAccess -> ()
rnf UpdateEndpointAccess' {Maybe [Text]
Text
endpointName :: Text
vpcSecurityGroupIds :: Maybe [Text]
$sel:endpointName:UpdateEndpointAccess' :: UpdateEndpointAccess -> Text
$sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: UpdateEndpointAccess -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
vpcSecurityGroupIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
endpointName

instance Data.ToHeaders UpdateEndpointAccess where
  toHeaders :: UpdateEndpointAccess -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"RedshiftServerless.UpdateEndpointAccess" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateEndpointAccess where
  toJSON :: UpdateEndpointAccess -> Value
toJSON UpdateEndpointAccess' {Maybe [Text]
Text
endpointName :: Text
vpcSecurityGroupIds :: Maybe [Text]
$sel:endpointName:UpdateEndpointAccess' :: UpdateEndpointAccess -> Text
$sel:vpcSecurityGroupIds:UpdateEndpointAccess' :: UpdateEndpointAccess -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"vpcSecurityGroupIds" 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]
vpcSecurityGroupIds,
            forall a. a -> Maybe a
Prelude.Just (Key
"endpointName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpointName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateEndpointAccessResponse' 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:
--
-- 'endpoint', 'updateEndpointAccessResponse_endpoint' - The updated VPC endpoint.
--
-- 'httpStatus', 'updateEndpointAccessResponse_httpStatus' - The response's http status code.
newUpdateEndpointAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateEndpointAccessResponse
newUpdateEndpointAccessResponse :: Int -> UpdateEndpointAccessResponse
newUpdateEndpointAccessResponse Int
pHttpStatus_ =
  UpdateEndpointAccessResponse'
    { $sel:endpoint:UpdateEndpointAccessResponse' :: Maybe EndpointAccess
endpoint =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateEndpointAccessResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated VPC endpoint.
updateEndpointAccessResponse_endpoint :: Lens.Lens' UpdateEndpointAccessResponse (Prelude.Maybe EndpointAccess)
updateEndpointAccessResponse_endpoint :: Lens' UpdateEndpointAccessResponse (Maybe EndpointAccess)
updateEndpointAccessResponse_endpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpointAccessResponse' {Maybe EndpointAccess
endpoint :: Maybe EndpointAccess
$sel:endpoint:UpdateEndpointAccessResponse' :: UpdateEndpointAccessResponse -> Maybe EndpointAccess
endpoint} -> Maybe EndpointAccess
endpoint) (\s :: UpdateEndpointAccessResponse
s@UpdateEndpointAccessResponse' {} Maybe EndpointAccess
a -> UpdateEndpointAccessResponse
s {$sel:endpoint:UpdateEndpointAccessResponse' :: Maybe EndpointAccess
endpoint = Maybe EndpointAccess
a} :: UpdateEndpointAccessResponse)

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

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