{-# 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.UpdateSite
-- 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 the information for an existing site. To remove information for
-- any of the parameters, specify an empty string.
module Amazonka.NetworkManager.UpdateSite
  ( -- * Creating a Request
    UpdateSite (..),
    newUpdateSite,

    -- * Request Lenses
    updateSite_description,
    updateSite_location,
    updateSite_globalNetworkId,
    updateSite_siteId,

    -- * Destructuring the Response
    UpdateSiteResponse (..),
    newUpdateSiteResponse,

    -- * Response Lenses
    updateSiteResponse_site,
    updateSiteResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateSite' smart constructor.
data UpdateSite = UpdateSite'
  { -- | A description of your site.
    --
    -- Constraints: Maximum length of 256 characters.
    UpdateSite -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The site location:
    --
    -- -   @Address@: The physical address of the site.
    --
    -- -   @Latitude@: The latitude of the site.
    --
    -- -   @Longitude@: The longitude of the site.
    UpdateSite -> Maybe (Sensitive Location)
location :: Prelude.Maybe (Data.Sensitive Location),
    -- | The ID of the global network.
    UpdateSite -> Text
globalNetworkId :: Prelude.Text,
    -- | The ID of your site.
    UpdateSite -> Text
siteId :: Prelude.Text
  }
  deriving (UpdateSite -> UpdateSite -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSite -> UpdateSite -> Bool
$c/= :: UpdateSite -> UpdateSite -> Bool
== :: UpdateSite -> UpdateSite -> Bool
$c== :: UpdateSite -> UpdateSite -> Bool
Prelude.Eq, Int -> UpdateSite -> ShowS
[UpdateSite] -> ShowS
UpdateSite -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSite] -> ShowS
$cshowList :: [UpdateSite] -> ShowS
show :: UpdateSite -> String
$cshow :: UpdateSite -> String
showsPrec :: Int -> UpdateSite -> ShowS
$cshowsPrec :: Int -> UpdateSite -> ShowS
Prelude.Show, forall x. Rep UpdateSite x -> UpdateSite
forall x. UpdateSite -> Rep UpdateSite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSite x -> UpdateSite
$cfrom :: forall x. UpdateSite -> Rep UpdateSite x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSite' 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', 'updateSite_description' - A description of your site.
--
-- Constraints: Maximum length of 256 characters.
--
-- 'location', 'updateSite_location' - The site location:
--
-- -   @Address@: The physical address of the site.
--
-- -   @Latitude@: The latitude of the site.
--
-- -   @Longitude@: The longitude of the site.
--
-- 'globalNetworkId', 'updateSite_globalNetworkId' - The ID of the global network.
--
-- 'siteId', 'updateSite_siteId' - The ID of your site.
newUpdateSite ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'siteId'
  Prelude.Text ->
  UpdateSite
newUpdateSite :: Text -> Text -> UpdateSite
newUpdateSite Text
pGlobalNetworkId_ Text
pSiteId_ =
  UpdateSite'
    { $sel:description:UpdateSite' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:location:UpdateSite' :: Maybe (Sensitive Location)
location = forall a. Maybe a
Prelude.Nothing,
      $sel:globalNetworkId:UpdateSite' :: Text
globalNetworkId = Text
pGlobalNetworkId_,
      $sel:siteId:UpdateSite' :: Text
siteId = Text
pSiteId_
    }

-- | A description of your site.
--
-- Constraints: Maximum length of 256 characters.
updateSite_description :: Lens.Lens' UpdateSite (Prelude.Maybe Prelude.Text)
updateSite_description :: Lens' UpdateSite (Maybe Text)
updateSite_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Maybe Text
description :: Maybe Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateSite
s@UpdateSite' {} Maybe Text
a -> UpdateSite
s {$sel:description:UpdateSite' :: Maybe Text
description = Maybe Text
a} :: UpdateSite)

-- | The site location:
--
-- -   @Address@: The physical address of the site.
--
-- -   @Latitude@: The latitude of the site.
--
-- -   @Longitude@: The longitude of the site.
updateSite_location :: Lens.Lens' UpdateSite (Prelude.Maybe Location)
updateSite_location :: Lens' UpdateSite (Maybe Location)
updateSite_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSite' {Maybe (Sensitive Location)
location :: Maybe (Sensitive Location)
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
location} -> Maybe (Sensitive Location)
location) (\s :: UpdateSite
s@UpdateSite' {} Maybe (Sensitive Location)
a -> UpdateSite
s {$sel:location:UpdateSite' :: Maybe (Sensitive Location)
location = Maybe (Sensitive Location)
a} :: UpdateSite) 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 a. Iso' (Sensitive a) a
Data._Sensitive

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

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

instance Core.AWSRequest UpdateSite where
  type AWSResponse UpdateSite = UpdateSiteResponse
  request :: (Service -> Service) -> UpdateSite -> Request UpdateSite
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateSite
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSite)))
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 Site -> Int -> UpdateSiteResponse
UpdateSiteResponse'
            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
"Site")
            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 UpdateSite where
  hashWithSalt :: Int -> UpdateSite -> Int
hashWithSalt Int
_salt UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
location :: Maybe (Sensitive Location)
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Location)
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
globalNetworkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
siteId

instance Prelude.NFData UpdateSite where
  rnf :: UpdateSite -> ()
rnf UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
location :: Maybe (Sensitive Location)
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Location)
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
globalNetworkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
siteId

instance Data.ToHeaders UpdateSite where
  toHeaders :: UpdateSite -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateSite where
  toJSON :: UpdateSite -> Value
toJSON UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
location :: Maybe (Sensitive Location)
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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
description,
            (Key
"Location" 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 (Sensitive Location)
location
          ]
      )

instance Data.ToPath UpdateSite where
  toPath :: UpdateSite -> ByteString
toPath UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
location :: Maybe (Sensitive Location)
description :: Maybe Text
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/global-networks/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
globalNetworkId,
        ByteString
"/sites/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
siteId
      ]

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

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

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

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

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

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