{-# 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.NetworkManager.DeleteSite
-- 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)
--
-- Deletes an existing site. The site cannot be associated with any device
-- or link.
module Amazonka.NetworkManager.DeleteSite
  ( -- * Creating a Request
    DeleteSite (..),
    newDeleteSite,

    -- * Request Lenses
    deleteSite_globalNetworkId,
    deleteSite_siteId,

    -- * Destructuring the Response
    DeleteSiteResponse (..),
    newDeleteSiteResponse,

    -- * Response Lenses
    deleteSiteResponse_site,
    deleteSiteResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteSite' smart constructor.
data DeleteSite = DeleteSite'
  { -- | The ID of the global network.
    DeleteSite -> Text
globalNetworkId :: Prelude.Text,
    -- | The ID of the site.
    DeleteSite -> Text
siteId :: Prelude.Text
  }
  deriving (DeleteSite -> DeleteSite -> Bool
(DeleteSite -> DeleteSite -> Bool)
-> (DeleteSite -> DeleteSite -> Bool) -> Eq DeleteSite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSite -> DeleteSite -> Bool
$c/= :: DeleteSite -> DeleteSite -> Bool
== :: DeleteSite -> DeleteSite -> Bool
$c== :: DeleteSite -> DeleteSite -> Bool
Prelude.Eq, ReadPrec [DeleteSite]
ReadPrec DeleteSite
Int -> ReadS DeleteSite
ReadS [DeleteSite]
(Int -> ReadS DeleteSite)
-> ReadS [DeleteSite]
-> ReadPrec DeleteSite
-> ReadPrec [DeleteSite]
-> Read DeleteSite
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSite]
$creadListPrec :: ReadPrec [DeleteSite]
readPrec :: ReadPrec DeleteSite
$creadPrec :: ReadPrec DeleteSite
readList :: ReadS [DeleteSite]
$creadList :: ReadS [DeleteSite]
readsPrec :: Int -> ReadS DeleteSite
$creadsPrec :: Int -> ReadS DeleteSite
Prelude.Read, Int -> DeleteSite -> ShowS
[DeleteSite] -> ShowS
DeleteSite -> String
(Int -> DeleteSite -> ShowS)
-> (DeleteSite -> String)
-> ([DeleteSite] -> ShowS)
-> Show DeleteSite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSite] -> ShowS
$cshowList :: [DeleteSite] -> ShowS
show :: DeleteSite -> String
$cshow :: DeleteSite -> String
showsPrec :: Int -> DeleteSite -> ShowS
$cshowsPrec :: Int -> DeleteSite -> ShowS
Prelude.Show, (forall x. DeleteSite -> Rep DeleteSite x)
-> (forall x. Rep DeleteSite x -> DeleteSite) -> Generic DeleteSite
forall x. Rep DeleteSite x -> DeleteSite
forall x. DeleteSite -> Rep DeleteSite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSite x -> DeleteSite
$cfrom :: forall x. DeleteSite -> Rep DeleteSite x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSite' 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:
--
-- 'globalNetworkId', 'deleteSite_globalNetworkId' - The ID of the global network.
--
-- 'siteId', 'deleteSite_siteId' - The ID of the site.
newDeleteSite ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'siteId'
  Prelude.Text ->
  DeleteSite
newDeleteSite :: Text -> Text -> DeleteSite
newDeleteSite Text
pGlobalNetworkId_ Text
pSiteId_ =
  DeleteSite' :: Text -> Text -> DeleteSite
DeleteSite'
    { $sel:globalNetworkId:DeleteSite' :: Text
globalNetworkId = Text
pGlobalNetworkId_,
      $sel:siteId:DeleteSite' :: Text
siteId = Text
pSiteId_
    }

-- | The ID of the global network.
deleteSite_globalNetworkId :: Lens.Lens' DeleteSite Prelude.Text
deleteSite_globalNetworkId :: (Text -> f Text) -> DeleteSite -> f DeleteSite
deleteSite_globalNetworkId = (DeleteSite -> Text)
-> (DeleteSite -> Text -> DeleteSite)
-> Lens DeleteSite DeleteSite Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSite' {Text
globalNetworkId :: Text
$sel:globalNetworkId:DeleteSite' :: DeleteSite -> Text
globalNetworkId} -> Text
globalNetworkId) (\s :: DeleteSite
s@DeleteSite' {} Text
a -> DeleteSite
s {$sel:globalNetworkId:DeleteSite' :: Text
globalNetworkId = Text
a} :: DeleteSite)

-- | The ID of the site.
deleteSite_siteId :: Lens.Lens' DeleteSite Prelude.Text
deleteSite_siteId :: (Text -> f Text) -> DeleteSite -> f DeleteSite
deleteSite_siteId = (DeleteSite -> Text)
-> (DeleteSite -> Text -> DeleteSite)
-> Lens DeleteSite DeleteSite Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSite' {Text
siteId :: Text
$sel:siteId:DeleteSite' :: DeleteSite -> Text
siteId} -> Text
siteId) (\s :: DeleteSite
s@DeleteSite' {} Text
a -> DeleteSite
s {$sel:siteId:DeleteSite' :: Text
siteId = Text
a} :: DeleteSite)

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

instance Prelude.NFData DeleteSite

instance Core.ToHeaders DeleteSite where
  toHeaders :: DeleteSite -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteSite -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteSite where
  toPath :: DeleteSite -> ByteString
toPath DeleteSite' {Text
siteId :: Text
globalNetworkId :: Text
$sel:siteId:DeleteSite' :: DeleteSite -> Text
$sel:globalNetworkId:DeleteSite' :: DeleteSite -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/global-networks/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
globalNetworkId,
        ByteString
"/sites/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
siteId
      ]

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

-- | /See:/ 'newDeleteSiteResponse' smart constructor.
data DeleteSiteResponse = DeleteSiteResponse'
  { -- | Information about the site.
    DeleteSiteResponse -> Maybe Site
site :: Prelude.Maybe Site,
    -- | The response's http status code.
    DeleteSiteResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteSiteResponse -> DeleteSiteResponse -> Bool
(DeleteSiteResponse -> DeleteSiteResponse -> Bool)
-> (DeleteSiteResponse -> DeleteSiteResponse -> Bool)
-> Eq DeleteSiteResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSiteResponse -> DeleteSiteResponse -> Bool
$c/= :: DeleteSiteResponse -> DeleteSiteResponse -> Bool
== :: DeleteSiteResponse -> DeleteSiteResponse -> Bool
$c== :: DeleteSiteResponse -> DeleteSiteResponse -> Bool
Prelude.Eq, Int -> DeleteSiteResponse -> ShowS
[DeleteSiteResponse] -> ShowS
DeleteSiteResponse -> String
(Int -> DeleteSiteResponse -> ShowS)
-> (DeleteSiteResponse -> String)
-> ([DeleteSiteResponse] -> ShowS)
-> Show DeleteSiteResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSiteResponse] -> ShowS
$cshowList :: [DeleteSiteResponse] -> ShowS
show :: DeleteSiteResponse -> String
$cshow :: DeleteSiteResponse -> String
showsPrec :: Int -> DeleteSiteResponse -> ShowS
$cshowsPrec :: Int -> DeleteSiteResponse -> ShowS
Prelude.Show, (forall x. DeleteSiteResponse -> Rep DeleteSiteResponse x)
-> (forall x. Rep DeleteSiteResponse x -> DeleteSiteResponse)
-> Generic DeleteSiteResponse
forall x. Rep DeleteSiteResponse x -> DeleteSiteResponse
forall x. DeleteSiteResponse -> Rep DeleteSiteResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSiteResponse x -> DeleteSiteResponse
$cfrom :: forall x. DeleteSiteResponse -> Rep DeleteSiteResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSiteResponse' 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:
--
-- 'site', 'deleteSiteResponse_site' - Information about the site.
--
-- 'httpStatus', 'deleteSiteResponse_httpStatus' - The response's http status code.
newDeleteSiteResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteSiteResponse
newDeleteSiteResponse :: Int -> DeleteSiteResponse
newDeleteSiteResponse Int
pHttpStatus_ =
  DeleteSiteResponse' :: Maybe Site -> Int -> DeleteSiteResponse
DeleteSiteResponse'
    { $sel:site:DeleteSiteResponse' :: Maybe Site
site = Maybe Site
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteSiteResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the site.
deleteSiteResponse_site :: Lens.Lens' DeleteSiteResponse (Prelude.Maybe Site)
deleteSiteResponse_site :: (Maybe Site -> f (Maybe Site))
-> DeleteSiteResponse -> f DeleteSiteResponse
deleteSiteResponse_site = (DeleteSiteResponse -> Maybe Site)
-> (DeleteSiteResponse -> Maybe Site -> DeleteSiteResponse)
-> Lens
     DeleteSiteResponse DeleteSiteResponse (Maybe Site) (Maybe Site)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSiteResponse' {Maybe Site
site :: Maybe Site
$sel:site:DeleteSiteResponse' :: DeleteSiteResponse -> Maybe Site
site} -> Maybe Site
site) (\s :: DeleteSiteResponse
s@DeleteSiteResponse' {} Maybe Site
a -> DeleteSiteResponse
s {$sel:site:DeleteSiteResponse' :: Maybe Site
site = Maybe Site
a} :: DeleteSiteResponse)

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

instance Prelude.NFData DeleteSiteResponse