{-# 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-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)
--
-- 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_location,
    updateSite_description,
    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.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:/ 'newUpdateSite' smart constructor.
data UpdateSite = UpdateSite'
  { -- | 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 (Core.Sensitive Location),
    -- | A description of your site.
    --
    -- Length Constraints: Maximum length of 256 characters.
    UpdateSite -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | 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
(UpdateSite -> UpdateSite -> Bool)
-> (UpdateSite -> UpdateSite -> Bool) -> Eq UpdateSite
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
(Int -> UpdateSite -> ShowS)
-> (UpdateSite -> String)
-> ([UpdateSite] -> ShowS)
-> Show UpdateSite
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. UpdateSite -> Rep UpdateSite x)
-> (forall x. Rep UpdateSite x -> UpdateSite) -> Generic UpdateSite
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:
--
-- '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.
--
-- 'description', 'updateSite_description' - A description of your site.
--
-- Length Constraints: Maximum length of 256 characters.
--
-- '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' :: Maybe (Sensitive Location)
-> Maybe Text -> Text -> Text -> UpdateSite
UpdateSite'
    { $sel:location:UpdateSite' :: Maybe (Sensitive Location)
location = Maybe (Sensitive Location)
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateSite' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:globalNetworkId:UpdateSite' :: Text
globalNetworkId = Text
pGlobalNetworkId_,
      $sel:siteId:UpdateSite' :: Text
siteId = Text
pSiteId_
    }

-- | 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 :: (Maybe Location -> f (Maybe Location))
-> UpdateSite -> f UpdateSite
updateSite_location = (UpdateSite -> Maybe (Sensitive Location))
-> (UpdateSite -> Maybe (Sensitive Location) -> UpdateSite)
-> Lens
     UpdateSite
     UpdateSite
     (Maybe (Sensitive Location))
     (Maybe (Sensitive 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) ((Maybe (Sensitive Location) -> f (Maybe (Sensitive Location)))
 -> UpdateSite -> f UpdateSite)
-> ((Maybe Location -> f (Maybe Location))
    -> Maybe (Sensitive Location) -> f (Maybe (Sensitive Location)))
-> (Maybe Location -> f (Maybe Location))
-> UpdateSite
-> f UpdateSite
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Location) (Sensitive Location) Location Location
-> Iso
     (Maybe (Sensitive Location))
     (Maybe (Sensitive Location))
     (Maybe Location)
     (Maybe Location)
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 (Sensitive Location) (Sensitive Location) Location Location
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | A description of your site.
--
-- Length Constraints: Maximum length of 256 characters.
updateSite_description :: Lens.Lens' UpdateSite (Prelude.Maybe Prelude.Text)
updateSite_description :: (Maybe Text -> f (Maybe Text)) -> UpdateSite -> f UpdateSite
updateSite_description = (UpdateSite -> Maybe Text)
-> (UpdateSite -> Maybe Text -> UpdateSite)
-> Lens UpdateSite UpdateSite (Maybe Text) (Maybe Text)
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 ID of the global network.
updateSite_globalNetworkId :: Lens.Lens' UpdateSite Prelude.Text
updateSite_globalNetworkId :: (Text -> f Text) -> UpdateSite -> f UpdateSite
updateSite_globalNetworkId = (UpdateSite -> Text)
-> (UpdateSite -> Text -> UpdateSite)
-> Lens UpdateSite UpdateSite Text Text
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 :: (Text -> f Text) -> UpdateSite -> f UpdateSite
updateSite_siteId = (UpdateSite -> Text)
-> (UpdateSite -> Text -> UpdateSite)
-> Lens UpdateSite UpdateSite Text Text
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 :: UpdateSite -> Request UpdateSite
request = Service -> UpdateSite -> Request UpdateSite
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateSite
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSite)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateSite))
-> Logger
-> Service
-> Proxy UpdateSite
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSite)))
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 -> UpdateSiteResponse
UpdateSiteResponse'
            (Maybe Site -> Int -> UpdateSiteResponse)
-> Either String (Maybe Site)
-> Either String (Int -> UpdateSiteResponse)
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 -> UpdateSiteResponse)
-> Either String Int -> Either String UpdateSiteResponse
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 UpdateSite

instance Prelude.NFData UpdateSite

instance Core.ToHeaders UpdateSite where
  toHeaders :: UpdateSite -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateSite -> 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.ToJSON UpdateSite where
  toJSON :: UpdateSite -> Value
toJSON UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
description :: Maybe Text
location :: Maybe (Sensitive Location)
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Location" Text -> Sensitive Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Location -> Pair)
-> Maybe (Sensitive Location) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Location)
location,
            (Text
"Description" 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
description
          ]
      )

instance Core.ToPath UpdateSite where
  toPath :: UpdateSite -> ByteString
toPath UpdateSite' {Maybe Text
Maybe (Sensitive Location)
Text
siteId :: Text
globalNetworkId :: Text
description :: Maybe Text
location :: Maybe (Sensitive Location)
$sel:siteId:UpdateSite' :: UpdateSite -> Text
$sel:globalNetworkId:UpdateSite' :: UpdateSite -> Text
$sel:description:UpdateSite' :: UpdateSite -> Maybe Text
$sel:location:UpdateSite' :: UpdateSite -> Maybe (Sensitive Location)
..} =
    [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 UpdateSite where
  toQuery :: UpdateSite -> QueryString
toQuery = QueryString -> UpdateSite -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateSiteResponse -> UpdateSiteResponse -> Bool)
-> (UpdateSiteResponse -> UpdateSiteResponse -> Bool)
-> Eq UpdateSiteResponse
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
(Int -> UpdateSiteResponse -> ShowS)
-> (UpdateSiteResponse -> String)
-> ([UpdateSiteResponse] -> ShowS)
-> Show UpdateSiteResponse
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. UpdateSiteResponse -> Rep UpdateSiteResponse x)
-> (forall x. Rep UpdateSiteResponse x -> UpdateSiteResponse)
-> Generic UpdateSiteResponse
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' :: Maybe Site -> Int -> UpdateSiteResponse
UpdateSiteResponse'
    { $sel:site:UpdateSiteResponse' :: Maybe Site
site = Maybe 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 :: (Maybe Site -> f (Maybe Site))
-> UpdateSiteResponse -> f UpdateSiteResponse
updateSiteResponse_site = (UpdateSiteResponse -> Maybe Site)
-> (UpdateSiteResponse -> Maybe Site -> UpdateSiteResponse)
-> Lens
     UpdateSiteResponse UpdateSiteResponse (Maybe Site) (Maybe 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 :: (Int -> f Int) -> UpdateSiteResponse -> f UpdateSiteResponse
updateSiteResponse_httpStatus = (UpdateSiteResponse -> Int)
-> (UpdateSiteResponse -> Int -> UpdateSiteResponse)
-> Lens UpdateSiteResponse UpdateSiteResponse Int Int
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