{-# 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.Connect.UpdateTrafficDistribution
-- 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 traffic distribution for a given traffic distribution group.
--
-- For more information about updating a traffic distribution group, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/update-telephony-traffic-distribution.html Update telephony traffic distribution across Amazon Web Services Regions>
-- in the /Amazon Connect Administrator Guide/.
module Amazonka.Connect.UpdateTrafficDistribution
  ( -- * Creating a Request
    UpdateTrafficDistribution (..),
    newUpdateTrafficDistribution,

    -- * Request Lenses
    updateTrafficDistribution_telephonyConfig,
    updateTrafficDistribution_id,

    -- * Destructuring the Response
    UpdateTrafficDistributionResponse (..),
    newUpdateTrafficDistributionResponse,

    -- * Response Lenses
    updateTrafficDistributionResponse_httpStatus,
  )
where

import Amazonka.Connect.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateTrafficDistribution' smart constructor.
data UpdateTrafficDistribution = UpdateTrafficDistribution'
  { -- | The distribution of traffic between the instance and its replica(s).
    UpdateTrafficDistribution -> Maybe TelephonyConfig
telephonyConfig :: Prelude.Maybe TelephonyConfig,
    -- | The identifier of the traffic distribution group. This can be the ID or
    -- the ARN if the API is being called in the Region where the traffic
    -- distribution group was created. The ARN must be provided if the call is
    -- from the replicated Region.
    UpdateTrafficDistribution -> Text
id :: Prelude.Text
  }
  deriving (UpdateTrafficDistribution -> UpdateTrafficDistribution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTrafficDistribution -> UpdateTrafficDistribution -> Bool
$c/= :: UpdateTrafficDistribution -> UpdateTrafficDistribution -> Bool
== :: UpdateTrafficDistribution -> UpdateTrafficDistribution -> Bool
$c== :: UpdateTrafficDistribution -> UpdateTrafficDistribution -> Bool
Prelude.Eq, ReadPrec [UpdateTrafficDistribution]
ReadPrec UpdateTrafficDistribution
Int -> ReadS UpdateTrafficDistribution
ReadS [UpdateTrafficDistribution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTrafficDistribution]
$creadListPrec :: ReadPrec [UpdateTrafficDistribution]
readPrec :: ReadPrec UpdateTrafficDistribution
$creadPrec :: ReadPrec UpdateTrafficDistribution
readList :: ReadS [UpdateTrafficDistribution]
$creadList :: ReadS [UpdateTrafficDistribution]
readsPrec :: Int -> ReadS UpdateTrafficDistribution
$creadsPrec :: Int -> ReadS UpdateTrafficDistribution
Prelude.Read, Int -> UpdateTrafficDistribution -> ShowS
[UpdateTrafficDistribution] -> ShowS
UpdateTrafficDistribution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTrafficDistribution] -> ShowS
$cshowList :: [UpdateTrafficDistribution] -> ShowS
show :: UpdateTrafficDistribution -> String
$cshow :: UpdateTrafficDistribution -> String
showsPrec :: Int -> UpdateTrafficDistribution -> ShowS
$cshowsPrec :: Int -> UpdateTrafficDistribution -> ShowS
Prelude.Show, forall x.
Rep UpdateTrafficDistribution x -> UpdateTrafficDistribution
forall x.
UpdateTrafficDistribution -> Rep UpdateTrafficDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateTrafficDistribution x -> UpdateTrafficDistribution
$cfrom :: forall x.
UpdateTrafficDistribution -> Rep UpdateTrafficDistribution x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTrafficDistribution' 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:
--
-- 'telephonyConfig', 'updateTrafficDistribution_telephonyConfig' - The distribution of traffic between the instance and its replica(s).
--
-- 'id', 'updateTrafficDistribution_id' - The identifier of the traffic distribution group. This can be the ID or
-- the ARN if the API is being called in the Region where the traffic
-- distribution group was created. The ARN must be provided if the call is
-- from the replicated Region.
newUpdateTrafficDistribution ::
  -- | 'id'
  Prelude.Text ->
  UpdateTrafficDistribution
newUpdateTrafficDistribution :: Text -> UpdateTrafficDistribution
newUpdateTrafficDistribution Text
pId_ =
  UpdateTrafficDistribution'
    { $sel:telephonyConfig:UpdateTrafficDistribution' :: Maybe TelephonyConfig
telephonyConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:id:UpdateTrafficDistribution' :: Text
id = Text
pId_
    }

-- | The distribution of traffic between the instance and its replica(s).
updateTrafficDistribution_telephonyConfig :: Lens.Lens' UpdateTrafficDistribution (Prelude.Maybe TelephonyConfig)
updateTrafficDistribution_telephonyConfig :: Lens' UpdateTrafficDistribution (Maybe TelephonyConfig)
updateTrafficDistribution_telephonyConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTrafficDistribution' {Maybe TelephonyConfig
telephonyConfig :: Maybe TelephonyConfig
$sel:telephonyConfig:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Maybe TelephonyConfig
telephonyConfig} -> Maybe TelephonyConfig
telephonyConfig) (\s :: UpdateTrafficDistribution
s@UpdateTrafficDistribution' {} Maybe TelephonyConfig
a -> UpdateTrafficDistribution
s {$sel:telephonyConfig:UpdateTrafficDistribution' :: Maybe TelephonyConfig
telephonyConfig = Maybe TelephonyConfig
a} :: UpdateTrafficDistribution)

-- | The identifier of the traffic distribution group. This can be the ID or
-- the ARN if the API is being called in the Region where the traffic
-- distribution group was created. The ARN must be provided if the call is
-- from the replicated Region.
updateTrafficDistribution_id :: Lens.Lens' UpdateTrafficDistribution Prelude.Text
updateTrafficDistribution_id :: Lens' UpdateTrafficDistribution Text
updateTrafficDistribution_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTrafficDistribution' {Text
id :: Text
$sel:id:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Text
id} -> Text
id) (\s :: UpdateTrafficDistribution
s@UpdateTrafficDistribution' {} Text
a -> UpdateTrafficDistribution
s {$sel:id:UpdateTrafficDistribution' :: Text
id = Text
a} :: UpdateTrafficDistribution)

instance Core.AWSRequest UpdateTrafficDistribution where
  type
    AWSResponse UpdateTrafficDistribution =
      UpdateTrafficDistributionResponse
  request :: (Service -> Service)
-> UpdateTrafficDistribution -> Request UpdateTrafficDistribution
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateTrafficDistribution
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateTrafficDistribution)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateTrafficDistributionResponse
UpdateTrafficDistributionResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateTrafficDistribution where
  hashWithSalt :: Int -> UpdateTrafficDistribution -> Int
hashWithSalt Int
_salt UpdateTrafficDistribution' {Maybe TelephonyConfig
Text
id :: Text
telephonyConfig :: Maybe TelephonyConfig
$sel:id:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Text
$sel:telephonyConfig:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Maybe TelephonyConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TelephonyConfig
telephonyConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData UpdateTrafficDistribution where
  rnf :: UpdateTrafficDistribution -> ()
rnf UpdateTrafficDistribution' {Maybe TelephonyConfig
Text
id :: Text
telephonyConfig :: Maybe TelephonyConfig
$sel:id:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Text
$sel:telephonyConfig:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Maybe TelephonyConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TelephonyConfig
telephonyConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders UpdateTrafficDistribution where
  toHeaders :: UpdateTrafficDistribution -> 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 UpdateTrafficDistribution where
  toJSON :: UpdateTrafficDistribution -> Value
toJSON UpdateTrafficDistribution' {Maybe TelephonyConfig
Text
id :: Text
telephonyConfig :: Maybe TelephonyConfig
$sel:id:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Text
$sel:telephonyConfig:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Maybe TelephonyConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TelephonyConfig" 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 TelephonyConfig
telephonyConfig
          ]
      )

instance Data.ToPath UpdateTrafficDistribution where
  toPath :: UpdateTrafficDistribution -> ByteString
toPath UpdateTrafficDistribution' {Maybe TelephonyConfig
Text
id :: Text
telephonyConfig :: Maybe TelephonyConfig
$sel:id:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Text
$sel:telephonyConfig:UpdateTrafficDistribution' :: UpdateTrafficDistribution -> Maybe TelephonyConfig
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/traffic-distribution/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

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

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

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

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

instance
  Prelude.NFData
    UpdateTrafficDistributionResponse
  where
  rnf :: UpdateTrafficDistributionResponse -> ()
rnf UpdateTrafficDistributionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateTrafficDistributionResponse' :: UpdateTrafficDistributionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus