{-# 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.GameLift.DeleteVpcPeeringConnection
-- 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)
--
-- Removes a VPC peering connection. To delete the connection, you must
-- have a valid authorization for the VPC peering connection that you want
-- to delete. You can check for an authorization by calling
-- DescribeVpcPeeringAuthorizations or request a new one using
-- CreateVpcPeeringAuthorization.
--
-- Once a valid authorization exists, call this operation from the AWS
-- account that is used to manage the Amazon GameLift fleets. Identify the
-- connection to delete by the connection ID and fleet ID. If successful,
-- the connection is removed.
--
-- __Related actions__
--
-- CreateVpcPeeringAuthorization | DescribeVpcPeeringAuthorizations |
-- DeleteVpcPeeringAuthorization | CreateVpcPeeringConnection |
-- DescribeVpcPeeringConnections | DeleteVpcPeeringConnection |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DeleteVpcPeeringConnection
  ( -- * Creating a Request
    DeleteVpcPeeringConnection (..),
    newDeleteVpcPeeringConnection,

    -- * Request Lenses
    deleteVpcPeeringConnection_fleetId,
    deleteVpcPeeringConnection_vpcPeeringConnectionId,

    -- * Destructuring the Response
    DeleteVpcPeeringConnectionResponse (..),
    newDeleteVpcPeeringConnectionResponse,

    -- * Response Lenses
    deleteVpcPeeringConnectionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.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

-- | Represents the input for a request operation.
--
-- /See:/ 'newDeleteVpcPeeringConnection' smart constructor.
data DeleteVpcPeeringConnection = DeleteVpcPeeringConnection'
  { -- | A unique identifier for the fleet. This fleet specified must match the
    -- fleet referenced in the VPC peering connection record. You can use
    -- either the fleet ID or ARN value.
    DeleteVpcPeeringConnection -> Text
fleetId :: Prelude.Text,
    -- | A unique identifier for a VPC peering connection. This value is included
    -- in the VpcPeeringConnection object, which can be retrieved by calling
    -- DescribeVpcPeeringConnections.
    DeleteVpcPeeringConnection -> Text
vpcPeeringConnectionId :: Prelude.Text
  }
  deriving (DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool
(DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool)
-> (DeleteVpcPeeringConnection
    -> DeleteVpcPeeringConnection -> Bool)
-> Eq DeleteVpcPeeringConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool
$c/= :: DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool
== :: DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool
$c== :: DeleteVpcPeeringConnection -> DeleteVpcPeeringConnection -> Bool
Prelude.Eq, ReadPrec [DeleteVpcPeeringConnection]
ReadPrec DeleteVpcPeeringConnection
Int -> ReadS DeleteVpcPeeringConnection
ReadS [DeleteVpcPeeringConnection]
(Int -> ReadS DeleteVpcPeeringConnection)
-> ReadS [DeleteVpcPeeringConnection]
-> ReadPrec DeleteVpcPeeringConnection
-> ReadPrec [DeleteVpcPeeringConnection]
-> Read DeleteVpcPeeringConnection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVpcPeeringConnection]
$creadListPrec :: ReadPrec [DeleteVpcPeeringConnection]
readPrec :: ReadPrec DeleteVpcPeeringConnection
$creadPrec :: ReadPrec DeleteVpcPeeringConnection
readList :: ReadS [DeleteVpcPeeringConnection]
$creadList :: ReadS [DeleteVpcPeeringConnection]
readsPrec :: Int -> ReadS DeleteVpcPeeringConnection
$creadsPrec :: Int -> ReadS DeleteVpcPeeringConnection
Prelude.Read, Int -> DeleteVpcPeeringConnection -> ShowS
[DeleteVpcPeeringConnection] -> ShowS
DeleteVpcPeeringConnection -> String
(Int -> DeleteVpcPeeringConnection -> ShowS)
-> (DeleteVpcPeeringConnection -> String)
-> ([DeleteVpcPeeringConnection] -> ShowS)
-> Show DeleteVpcPeeringConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVpcPeeringConnection] -> ShowS
$cshowList :: [DeleteVpcPeeringConnection] -> ShowS
show :: DeleteVpcPeeringConnection -> String
$cshow :: DeleteVpcPeeringConnection -> String
showsPrec :: Int -> DeleteVpcPeeringConnection -> ShowS
$cshowsPrec :: Int -> DeleteVpcPeeringConnection -> ShowS
Prelude.Show, (forall x.
 DeleteVpcPeeringConnection -> Rep DeleteVpcPeeringConnection x)
-> (forall x.
    Rep DeleteVpcPeeringConnection x -> DeleteVpcPeeringConnection)
-> Generic DeleteVpcPeeringConnection
forall x.
Rep DeleteVpcPeeringConnection x -> DeleteVpcPeeringConnection
forall x.
DeleteVpcPeeringConnection -> Rep DeleteVpcPeeringConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteVpcPeeringConnection x -> DeleteVpcPeeringConnection
$cfrom :: forall x.
DeleteVpcPeeringConnection -> Rep DeleteVpcPeeringConnection x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVpcPeeringConnection' 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:
--
-- 'fleetId', 'deleteVpcPeeringConnection_fleetId' - A unique identifier for the fleet. This fleet specified must match the
-- fleet referenced in the VPC peering connection record. You can use
-- either the fleet ID or ARN value.
--
-- 'vpcPeeringConnectionId', 'deleteVpcPeeringConnection_vpcPeeringConnectionId' - A unique identifier for a VPC peering connection. This value is included
-- in the VpcPeeringConnection object, which can be retrieved by calling
-- DescribeVpcPeeringConnections.
newDeleteVpcPeeringConnection ::
  -- | 'fleetId'
  Prelude.Text ->
  -- | 'vpcPeeringConnectionId'
  Prelude.Text ->
  DeleteVpcPeeringConnection
newDeleteVpcPeeringConnection :: Text -> Text -> DeleteVpcPeeringConnection
newDeleteVpcPeeringConnection
  Text
pFleetId_
  Text
pVpcPeeringConnectionId_ =
    DeleteVpcPeeringConnection' :: Text -> Text -> DeleteVpcPeeringConnection
DeleteVpcPeeringConnection'
      { $sel:fleetId:DeleteVpcPeeringConnection' :: Text
fleetId = Text
pFleetId_,
        $sel:vpcPeeringConnectionId:DeleteVpcPeeringConnection' :: Text
vpcPeeringConnectionId =
          Text
pVpcPeeringConnectionId_
      }

-- | A unique identifier for the fleet. This fleet specified must match the
-- fleet referenced in the VPC peering connection record. You can use
-- either the fleet ID or ARN value.
deleteVpcPeeringConnection_fleetId :: Lens.Lens' DeleteVpcPeeringConnection Prelude.Text
deleteVpcPeeringConnection_fleetId :: (Text -> f Text)
-> DeleteVpcPeeringConnection -> f DeleteVpcPeeringConnection
deleteVpcPeeringConnection_fleetId = (DeleteVpcPeeringConnection -> Text)
-> (DeleteVpcPeeringConnection
    -> Text -> DeleteVpcPeeringConnection)
-> Lens
     DeleteVpcPeeringConnection DeleteVpcPeeringConnection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcPeeringConnection' {Text
fleetId :: Text
$sel:fleetId:DeleteVpcPeeringConnection' :: DeleteVpcPeeringConnection -> Text
fleetId} -> Text
fleetId) (\s :: DeleteVpcPeeringConnection
s@DeleteVpcPeeringConnection' {} Text
a -> DeleteVpcPeeringConnection
s {$sel:fleetId:DeleteVpcPeeringConnection' :: Text
fleetId = Text
a} :: DeleteVpcPeeringConnection)

-- | A unique identifier for a VPC peering connection. This value is included
-- in the VpcPeeringConnection object, which can be retrieved by calling
-- DescribeVpcPeeringConnections.
deleteVpcPeeringConnection_vpcPeeringConnectionId :: Lens.Lens' DeleteVpcPeeringConnection Prelude.Text
deleteVpcPeeringConnection_vpcPeeringConnectionId :: (Text -> f Text)
-> DeleteVpcPeeringConnection -> f DeleteVpcPeeringConnection
deleteVpcPeeringConnection_vpcPeeringConnectionId = (DeleteVpcPeeringConnection -> Text)
-> (DeleteVpcPeeringConnection
    -> Text -> DeleteVpcPeeringConnection)
-> Lens
     DeleteVpcPeeringConnection DeleteVpcPeeringConnection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVpcPeeringConnection' {Text
vpcPeeringConnectionId :: Text
$sel:vpcPeeringConnectionId:DeleteVpcPeeringConnection' :: DeleteVpcPeeringConnection -> Text
vpcPeeringConnectionId} -> Text
vpcPeeringConnectionId) (\s :: DeleteVpcPeeringConnection
s@DeleteVpcPeeringConnection' {} Text
a -> DeleteVpcPeeringConnection
s {$sel:vpcPeeringConnectionId:DeleteVpcPeeringConnection' :: Text
vpcPeeringConnectionId = Text
a} :: DeleteVpcPeeringConnection)

instance Core.AWSRequest DeleteVpcPeeringConnection where
  type
    AWSResponse DeleteVpcPeeringConnection =
      DeleteVpcPeeringConnectionResponse
  request :: DeleteVpcPeeringConnection -> Request DeleteVpcPeeringConnection
request = Service
-> DeleteVpcPeeringConnection -> Request DeleteVpcPeeringConnection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteVpcPeeringConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteVpcPeeringConnection)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteVpcPeeringConnection))
-> Logger
-> Service
-> Proxy DeleteVpcPeeringConnection
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteVpcPeeringConnection)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteVpcPeeringConnectionResponse
DeleteVpcPeeringConnectionResponse'
            (Int -> DeleteVpcPeeringConnectionResponse)
-> Either String Int
-> Either String DeleteVpcPeeringConnectionResponse
forall (f :: * -> *) a b. Functor 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 DeleteVpcPeeringConnection

instance Prelude.NFData DeleteVpcPeeringConnection

instance Core.ToHeaders DeleteVpcPeeringConnection where
  toHeaders :: DeleteVpcPeeringConnection -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteVpcPeeringConnection -> 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
"GameLift.DeleteVpcPeeringConnection" ::
                          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 DeleteVpcPeeringConnection where
  toJSON :: DeleteVpcPeeringConnection -> Value
toJSON DeleteVpcPeeringConnection' {Text
vpcPeeringConnectionId :: Text
fleetId :: Text
$sel:vpcPeeringConnectionId:DeleteVpcPeeringConnection' :: DeleteVpcPeeringConnection -> Text
$sel:fleetId:DeleteVpcPeeringConnection' :: DeleteVpcPeeringConnection -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"VpcPeeringConnectionId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
vpcPeeringConnectionId
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteVpcPeeringConnectionResponse' 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:
--
-- 'httpStatus', 'deleteVpcPeeringConnectionResponse_httpStatus' - The response's http status code.
newDeleteVpcPeeringConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteVpcPeeringConnectionResponse
newDeleteVpcPeeringConnectionResponse :: Int -> DeleteVpcPeeringConnectionResponse
newDeleteVpcPeeringConnectionResponse Int
pHttpStatus_ =
  DeleteVpcPeeringConnectionResponse' :: Int -> DeleteVpcPeeringConnectionResponse
DeleteVpcPeeringConnectionResponse'
    { $sel:httpStatus:DeleteVpcPeeringConnectionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DeleteVpcPeeringConnectionResponse