{-# 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.ChimeSdkVoice.UpdateSipRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- -- | Undocumented operation.
module Amazonka.ChimeSdkVoice.UpdateSipRule
  ( -- * Creating a Request
    UpdateSipRule (..),
    newUpdateSipRule,

    -- * Request Lenses
    updateSipRule_disabled,
    updateSipRule_targetApplications,
    updateSipRule_sipRuleId,
    updateSipRule_name,

    -- * Destructuring the Response
    UpdateSipRuleResponse (..),
    newUpdateSipRuleResponse,

    -- * Response Lenses
    updateSipRuleResponse_sipRule,
    updateSipRuleResponse_httpStatus,
  )
where

import Amazonka.ChimeSdkVoice.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:/ 'newUpdateSipRule' smart constructor.
data UpdateSipRule = UpdateSipRule'
  { UpdateSipRule -> Maybe Bool
disabled :: Prelude.Maybe Prelude.Bool,
    UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
targetApplications :: Prelude.Maybe (Prelude.NonEmpty SipRuleTargetApplication),
    UpdateSipRule -> Text
sipRuleId :: Prelude.Text,
    UpdateSipRule -> Text
name :: Prelude.Text
  }
  deriving (UpdateSipRule -> UpdateSipRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSipRule -> UpdateSipRule -> Bool
$c/= :: UpdateSipRule -> UpdateSipRule -> Bool
== :: UpdateSipRule -> UpdateSipRule -> Bool
$c== :: UpdateSipRule -> UpdateSipRule -> Bool
Prelude.Eq, ReadPrec [UpdateSipRule]
ReadPrec UpdateSipRule
Int -> ReadS UpdateSipRule
ReadS [UpdateSipRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSipRule]
$creadListPrec :: ReadPrec [UpdateSipRule]
readPrec :: ReadPrec UpdateSipRule
$creadPrec :: ReadPrec UpdateSipRule
readList :: ReadS [UpdateSipRule]
$creadList :: ReadS [UpdateSipRule]
readsPrec :: Int -> ReadS UpdateSipRule
$creadsPrec :: Int -> ReadS UpdateSipRule
Prelude.Read, Int -> UpdateSipRule -> ShowS
[UpdateSipRule] -> ShowS
UpdateSipRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSipRule] -> ShowS
$cshowList :: [UpdateSipRule] -> ShowS
show :: UpdateSipRule -> String
$cshow :: UpdateSipRule -> String
showsPrec :: Int -> UpdateSipRule -> ShowS
$cshowsPrec :: Int -> UpdateSipRule -> ShowS
Prelude.Show, forall x. Rep UpdateSipRule x -> UpdateSipRule
forall x. UpdateSipRule -> Rep UpdateSipRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSipRule x -> UpdateSipRule
$cfrom :: forall x. UpdateSipRule -> Rep UpdateSipRule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSipRule' 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:
--
-- 'disabled', 'updateSipRule_disabled' - Undocumented member.
--
-- 'targetApplications', 'updateSipRule_targetApplications' - Undocumented member.
--
-- 'sipRuleId', 'updateSipRule_sipRuleId' - Undocumented member.
--
-- 'name', 'updateSipRule_name' - Undocumented member.
newUpdateSipRule ::
  -- | 'sipRuleId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  UpdateSipRule
newUpdateSipRule :: Text -> Text -> UpdateSipRule
newUpdateSipRule Text
pSipRuleId_ Text
pName_ =
  UpdateSipRule'
    { $sel:disabled:UpdateSipRule' :: Maybe Bool
disabled = forall a. Maybe a
Prelude.Nothing,
      $sel:targetApplications:UpdateSipRule' :: Maybe (NonEmpty SipRuleTargetApplication)
targetApplications = forall a. Maybe a
Prelude.Nothing,
      $sel:sipRuleId:UpdateSipRule' :: Text
sipRuleId = Text
pSipRuleId_,
      $sel:name:UpdateSipRule' :: Text
name = Text
pName_
    }

-- | Undocumented member.
updateSipRule_disabled :: Lens.Lens' UpdateSipRule (Prelude.Maybe Prelude.Bool)
updateSipRule_disabled :: Lens' UpdateSipRule (Maybe Bool)
updateSipRule_disabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSipRule' {Maybe Bool
disabled :: Maybe Bool
$sel:disabled:UpdateSipRule' :: UpdateSipRule -> Maybe Bool
disabled} -> Maybe Bool
disabled) (\s :: UpdateSipRule
s@UpdateSipRule' {} Maybe Bool
a -> UpdateSipRule
s {$sel:disabled:UpdateSipRule' :: Maybe Bool
disabled = Maybe Bool
a} :: UpdateSipRule)

-- | Undocumented member.
updateSipRule_targetApplications :: Lens.Lens' UpdateSipRule (Prelude.Maybe (Prelude.NonEmpty SipRuleTargetApplication))
updateSipRule_targetApplications :: Lens' UpdateSipRule (Maybe (NonEmpty SipRuleTargetApplication))
updateSipRule_targetApplications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSipRule' {Maybe (NonEmpty SipRuleTargetApplication)
targetApplications :: Maybe (NonEmpty SipRuleTargetApplication)
$sel:targetApplications:UpdateSipRule' :: UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
targetApplications} -> Maybe (NonEmpty SipRuleTargetApplication)
targetApplications) (\s :: UpdateSipRule
s@UpdateSipRule' {} Maybe (NonEmpty SipRuleTargetApplication)
a -> UpdateSipRule
s {$sel:targetApplications:UpdateSipRule' :: Maybe (NonEmpty SipRuleTargetApplication)
targetApplications = Maybe (NonEmpty SipRuleTargetApplication)
a} :: UpdateSipRule) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
updateSipRule_sipRuleId :: Lens.Lens' UpdateSipRule Prelude.Text
updateSipRule_sipRuleId :: Lens' UpdateSipRule Text
updateSipRule_sipRuleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSipRule' {Text
sipRuleId :: Text
$sel:sipRuleId:UpdateSipRule' :: UpdateSipRule -> Text
sipRuleId} -> Text
sipRuleId) (\s :: UpdateSipRule
s@UpdateSipRule' {} Text
a -> UpdateSipRule
s {$sel:sipRuleId:UpdateSipRule' :: Text
sipRuleId = Text
a} :: UpdateSipRule)

-- | Undocumented member.
updateSipRule_name :: Lens.Lens' UpdateSipRule Prelude.Text
updateSipRule_name :: Lens' UpdateSipRule Text
updateSipRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSipRule' {Text
name :: Text
$sel:name:UpdateSipRule' :: UpdateSipRule -> Text
name} -> Text
name) (\s :: UpdateSipRule
s@UpdateSipRule' {} Text
a -> UpdateSipRule
s {$sel:name:UpdateSipRule' :: Text
name = Text
a} :: UpdateSipRule)

instance Core.AWSRequest UpdateSipRule where
  type
    AWSResponse UpdateSipRule =
      UpdateSipRuleResponse
  request :: (Service -> Service) -> UpdateSipRule -> Request UpdateSipRule
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 UpdateSipRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSipRule)))
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 SipRule -> Int -> UpdateSipRuleResponse
UpdateSipRuleResponse'
            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
"SipRule")
            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 UpdateSipRule where
  hashWithSalt :: Int -> UpdateSipRule -> Int
hashWithSalt Int
_salt UpdateSipRule' {Maybe Bool
Maybe (NonEmpty SipRuleTargetApplication)
Text
name :: Text
sipRuleId :: Text
targetApplications :: Maybe (NonEmpty SipRuleTargetApplication)
disabled :: Maybe Bool
$sel:name:UpdateSipRule' :: UpdateSipRule -> Text
$sel:sipRuleId:UpdateSipRule' :: UpdateSipRule -> Text
$sel:targetApplications:UpdateSipRule' :: UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
$sel:disabled:UpdateSipRule' :: UpdateSipRule -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
disabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty SipRuleTargetApplication)
targetApplications
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sipRuleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData UpdateSipRule where
  rnf :: UpdateSipRule -> ()
rnf UpdateSipRule' {Maybe Bool
Maybe (NonEmpty SipRuleTargetApplication)
Text
name :: Text
sipRuleId :: Text
targetApplications :: Maybe (NonEmpty SipRuleTargetApplication)
disabled :: Maybe Bool
$sel:name:UpdateSipRule' :: UpdateSipRule -> Text
$sel:sipRuleId:UpdateSipRule' :: UpdateSipRule -> Text
$sel:targetApplications:UpdateSipRule' :: UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
$sel:disabled:UpdateSipRule' :: UpdateSipRule -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
disabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty SipRuleTargetApplication)
targetApplications
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sipRuleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders UpdateSipRule where
  toHeaders :: UpdateSipRule -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON UpdateSipRule where
  toJSON :: UpdateSipRule -> Value
toJSON UpdateSipRule' {Maybe Bool
Maybe (NonEmpty SipRuleTargetApplication)
Text
name :: Text
sipRuleId :: Text
targetApplications :: Maybe (NonEmpty SipRuleTargetApplication)
disabled :: Maybe Bool
$sel:name:UpdateSipRule' :: UpdateSipRule -> Text
$sel:sipRuleId:UpdateSipRule' :: UpdateSipRule -> Text
$sel:targetApplications:UpdateSipRule' :: UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
$sel:disabled:UpdateSipRule' :: UpdateSipRule -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Disabled" 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 Bool
disabled,
            (Key
"TargetApplications" 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 (NonEmpty SipRuleTargetApplication)
targetApplications,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )

instance Data.ToPath UpdateSipRule where
  toPath :: UpdateSipRule -> ByteString
toPath UpdateSipRule' {Maybe Bool
Maybe (NonEmpty SipRuleTargetApplication)
Text
name :: Text
sipRuleId :: Text
targetApplications :: Maybe (NonEmpty SipRuleTargetApplication)
disabled :: Maybe Bool
$sel:name:UpdateSipRule' :: UpdateSipRule -> Text
$sel:sipRuleId:UpdateSipRule' :: UpdateSipRule -> Text
$sel:targetApplications:UpdateSipRule' :: UpdateSipRule -> Maybe (NonEmpty SipRuleTargetApplication)
$sel:disabled:UpdateSipRule' :: UpdateSipRule -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/sip-rules/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
sipRuleId]

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

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

-- |
-- Create a value of 'UpdateSipRuleResponse' 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:
--
-- 'sipRule', 'updateSipRuleResponse_sipRule' - Undocumented member.
--
-- 'httpStatus', 'updateSipRuleResponse_httpStatus' - The response's http status code.
newUpdateSipRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSipRuleResponse
newUpdateSipRuleResponse :: Int -> UpdateSipRuleResponse
newUpdateSipRuleResponse Int
pHttpStatus_ =
  UpdateSipRuleResponse'
    { $sel:sipRule:UpdateSipRuleResponse' :: Maybe SipRule
sipRule = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSipRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateSipRuleResponse_sipRule :: Lens.Lens' UpdateSipRuleResponse (Prelude.Maybe SipRule)
updateSipRuleResponse_sipRule :: Lens' UpdateSipRuleResponse (Maybe SipRule)
updateSipRuleResponse_sipRule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSipRuleResponse' {Maybe SipRule
sipRule :: Maybe SipRule
$sel:sipRule:UpdateSipRuleResponse' :: UpdateSipRuleResponse -> Maybe SipRule
sipRule} -> Maybe SipRule
sipRule) (\s :: UpdateSipRuleResponse
s@UpdateSipRuleResponse' {} Maybe SipRule
a -> UpdateSipRuleResponse
s {$sel:sipRule:UpdateSipRuleResponse' :: Maybe SipRule
sipRule = Maybe SipRule
a} :: UpdateSipRuleResponse)

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

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