{-# 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.ELBV2.SetRulePriorities
-- 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)
--
-- Sets the priorities of the specified rules.
--
-- You can reorder the rules as long as there are no priority conflicts in
-- the new order. Any existing rules that you do not specify retain their
-- current priority.
module Amazonka.ELBV2.SetRulePriorities
  ( -- * Creating a Request
    SetRulePriorities (..),
    newSetRulePriorities,

    -- * Request Lenses
    setRulePriorities_rulePriorities,

    -- * Destructuring the Response
    SetRulePrioritiesResponse (..),
    newSetRulePrioritiesResponse,

    -- * Response Lenses
    setRulePrioritiesResponse_rules,
    setRulePrioritiesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newSetRulePriorities' smart constructor.
data SetRulePriorities = SetRulePriorities'
  { -- | The rule priorities.
    SetRulePriorities -> [RulePriorityPair]
rulePriorities :: [RulePriorityPair]
  }
  deriving (SetRulePriorities -> SetRulePriorities -> Bool
(SetRulePriorities -> SetRulePriorities -> Bool)
-> (SetRulePriorities -> SetRulePriorities -> Bool)
-> Eq SetRulePriorities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetRulePriorities -> SetRulePriorities -> Bool
$c/= :: SetRulePriorities -> SetRulePriorities -> Bool
== :: SetRulePriorities -> SetRulePriorities -> Bool
$c== :: SetRulePriorities -> SetRulePriorities -> Bool
Prelude.Eq, ReadPrec [SetRulePriorities]
ReadPrec SetRulePriorities
Int -> ReadS SetRulePriorities
ReadS [SetRulePriorities]
(Int -> ReadS SetRulePriorities)
-> ReadS [SetRulePriorities]
-> ReadPrec SetRulePriorities
-> ReadPrec [SetRulePriorities]
-> Read SetRulePriorities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetRulePriorities]
$creadListPrec :: ReadPrec [SetRulePriorities]
readPrec :: ReadPrec SetRulePriorities
$creadPrec :: ReadPrec SetRulePriorities
readList :: ReadS [SetRulePriorities]
$creadList :: ReadS [SetRulePriorities]
readsPrec :: Int -> ReadS SetRulePriorities
$creadsPrec :: Int -> ReadS SetRulePriorities
Prelude.Read, Int -> SetRulePriorities -> ShowS
[SetRulePriorities] -> ShowS
SetRulePriorities -> String
(Int -> SetRulePriorities -> ShowS)
-> (SetRulePriorities -> String)
-> ([SetRulePriorities] -> ShowS)
-> Show SetRulePriorities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetRulePriorities] -> ShowS
$cshowList :: [SetRulePriorities] -> ShowS
show :: SetRulePriorities -> String
$cshow :: SetRulePriorities -> String
showsPrec :: Int -> SetRulePriorities -> ShowS
$cshowsPrec :: Int -> SetRulePriorities -> ShowS
Prelude.Show, (forall x. SetRulePriorities -> Rep SetRulePriorities x)
-> (forall x. Rep SetRulePriorities x -> SetRulePriorities)
-> Generic SetRulePriorities
forall x. Rep SetRulePriorities x -> SetRulePriorities
forall x. SetRulePriorities -> Rep SetRulePriorities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetRulePriorities x -> SetRulePriorities
$cfrom :: forall x. SetRulePriorities -> Rep SetRulePriorities x
Prelude.Generic)

-- |
-- Create a value of 'SetRulePriorities' 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:
--
-- 'rulePriorities', 'setRulePriorities_rulePriorities' - The rule priorities.
newSetRulePriorities ::
  SetRulePriorities
newSetRulePriorities :: SetRulePriorities
newSetRulePriorities =
  SetRulePriorities' :: [RulePriorityPair] -> SetRulePriorities
SetRulePriorities' {$sel:rulePriorities:SetRulePriorities' :: [RulePriorityPair]
rulePriorities = [RulePriorityPair]
forall a. Monoid a => a
Prelude.mempty}

-- | The rule priorities.
setRulePriorities_rulePriorities :: Lens.Lens' SetRulePriorities [RulePriorityPair]
setRulePriorities_rulePriorities :: ([RulePriorityPair] -> f [RulePriorityPair])
-> SetRulePriorities -> f SetRulePriorities
setRulePriorities_rulePriorities = (SetRulePriorities -> [RulePriorityPair])
-> (SetRulePriorities -> [RulePriorityPair] -> SetRulePriorities)
-> Lens
     SetRulePriorities
     SetRulePriorities
     [RulePriorityPair]
     [RulePriorityPair]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetRulePriorities' {[RulePriorityPair]
rulePriorities :: [RulePriorityPair]
$sel:rulePriorities:SetRulePriorities' :: SetRulePriorities -> [RulePriorityPair]
rulePriorities} -> [RulePriorityPair]
rulePriorities) (\s :: SetRulePriorities
s@SetRulePriorities' {} [RulePriorityPair]
a -> SetRulePriorities
s {$sel:rulePriorities:SetRulePriorities' :: [RulePriorityPair]
rulePriorities = [RulePriorityPair]
a} :: SetRulePriorities) (([RulePriorityPair] -> f [RulePriorityPair])
 -> SetRulePriorities -> f SetRulePriorities)
-> (([RulePriorityPair] -> f [RulePriorityPair])
    -> [RulePriorityPair] -> f [RulePriorityPair])
-> ([RulePriorityPair] -> f [RulePriorityPair])
-> SetRulePriorities
-> f SetRulePriorities
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([RulePriorityPair] -> f [RulePriorityPair])
-> [RulePriorityPair] -> f [RulePriorityPair]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest SetRulePriorities where
  type
    AWSResponse SetRulePriorities =
      SetRulePrioritiesResponse
  request :: SetRulePriorities -> Request SetRulePriorities
request = Service -> SetRulePriorities -> Request SetRulePriorities
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetRulePriorities
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetRulePriorities)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse SetRulePriorities))
-> Logger
-> Service
-> Proxy SetRulePriorities
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetRulePriorities)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"SetRulePrioritiesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Rule] -> Int -> SetRulePrioritiesResponse
SetRulePrioritiesResponse'
            (Maybe [Rule] -> Int -> SetRulePrioritiesResponse)
-> Either String (Maybe [Rule])
-> Either String (Int -> SetRulePrioritiesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Rules" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Rule]))
-> Either String (Maybe [Rule])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Rule])
-> [Node] -> Either String (Maybe [Rule])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Rule]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> SetRulePrioritiesResponse)
-> Either String Int -> Either String SetRulePrioritiesResponse
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 SetRulePriorities

instance Prelude.NFData SetRulePriorities

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

instance Core.ToPath SetRulePriorities where
  toPath :: SetRulePriorities -> ByteString
toPath = ByteString -> SetRulePriorities -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery SetRulePriorities where
  toQuery :: SetRulePriorities -> QueryString
toQuery SetRulePriorities' {[RulePriorityPair]
rulePriorities :: [RulePriorityPair]
$sel:rulePriorities:SetRulePriorities' :: SetRulePriorities -> [RulePriorityPair]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetRulePriorities" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
        ByteString
"RulePriorities"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [RulePriorityPair] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [RulePriorityPair]
rulePriorities
      ]

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

-- |
-- Create a value of 'SetRulePrioritiesResponse' 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:
--
-- 'rules', 'setRulePrioritiesResponse_rules' - Information about the rules.
--
-- 'httpStatus', 'setRulePrioritiesResponse_httpStatus' - The response's http status code.
newSetRulePrioritiesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SetRulePrioritiesResponse
newSetRulePrioritiesResponse :: Int -> SetRulePrioritiesResponse
newSetRulePrioritiesResponse Int
pHttpStatus_ =
  SetRulePrioritiesResponse' :: Maybe [Rule] -> Int -> SetRulePrioritiesResponse
SetRulePrioritiesResponse'
    { $sel:rules:SetRulePrioritiesResponse' :: Maybe [Rule]
rules = Maybe [Rule]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SetRulePrioritiesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the rules.
setRulePrioritiesResponse_rules :: Lens.Lens' SetRulePrioritiesResponse (Prelude.Maybe [Rule])
setRulePrioritiesResponse_rules :: (Maybe [Rule] -> f (Maybe [Rule]))
-> SetRulePrioritiesResponse -> f SetRulePrioritiesResponse
setRulePrioritiesResponse_rules = (SetRulePrioritiesResponse -> Maybe [Rule])
-> (SetRulePrioritiesResponse
    -> Maybe [Rule] -> SetRulePrioritiesResponse)
-> Lens
     SetRulePrioritiesResponse
     SetRulePrioritiesResponse
     (Maybe [Rule])
     (Maybe [Rule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetRulePrioritiesResponse' {Maybe [Rule]
rules :: Maybe [Rule]
$sel:rules:SetRulePrioritiesResponse' :: SetRulePrioritiesResponse -> Maybe [Rule]
rules} -> Maybe [Rule]
rules) (\s :: SetRulePrioritiesResponse
s@SetRulePrioritiesResponse' {} Maybe [Rule]
a -> SetRulePrioritiesResponse
s {$sel:rules:SetRulePrioritiesResponse' :: Maybe [Rule]
rules = Maybe [Rule]
a} :: SetRulePrioritiesResponse) ((Maybe [Rule] -> f (Maybe [Rule]))
 -> SetRulePrioritiesResponse -> f SetRulePrioritiesResponse)
-> ((Maybe [Rule] -> f (Maybe [Rule]))
    -> Maybe [Rule] -> f (Maybe [Rule]))
-> (Maybe [Rule] -> f (Maybe [Rule]))
-> SetRulePrioritiesResponse
-> f SetRulePrioritiesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Rule] [Rule] [Rule] [Rule]
-> Iso (Maybe [Rule]) (Maybe [Rule]) (Maybe [Rule]) (Maybe [Rule])
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 [Rule] [Rule] [Rule] [Rule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData SetRulePrioritiesResponse