{-# 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.AlexaBusiness.RevokeInvitation
-- 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)
--
-- Revokes an invitation and invalidates the enrollment URL.
module Amazonka.AlexaBusiness.RevokeInvitation
  ( -- * Creating a Request
    RevokeInvitation (..),
    newRevokeInvitation,

    -- * Request Lenses
    revokeInvitation_enrollmentId,
    revokeInvitation_userArn,

    -- * Destructuring the Response
    RevokeInvitationResponse (..),
    newRevokeInvitationResponse,

    -- * Response Lenses
    revokeInvitationResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.Types
import qualified Amazonka.Core as Core
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:/ 'newRevokeInvitation' smart constructor.
data RevokeInvitation = RevokeInvitation'
  { -- | The ARN of the enrollment invitation to revoke. Required.
    RevokeInvitation -> Maybe Text
enrollmentId :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the user for whom to revoke an enrollment invitation.
    -- Required.
    RevokeInvitation -> Maybe Text
userArn :: Prelude.Maybe Prelude.Text
  }
  deriving (RevokeInvitation -> RevokeInvitation -> Bool
(RevokeInvitation -> RevokeInvitation -> Bool)
-> (RevokeInvitation -> RevokeInvitation -> Bool)
-> Eq RevokeInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevokeInvitation -> RevokeInvitation -> Bool
$c/= :: RevokeInvitation -> RevokeInvitation -> Bool
== :: RevokeInvitation -> RevokeInvitation -> Bool
$c== :: RevokeInvitation -> RevokeInvitation -> Bool
Prelude.Eq, ReadPrec [RevokeInvitation]
ReadPrec RevokeInvitation
Int -> ReadS RevokeInvitation
ReadS [RevokeInvitation]
(Int -> ReadS RevokeInvitation)
-> ReadS [RevokeInvitation]
-> ReadPrec RevokeInvitation
-> ReadPrec [RevokeInvitation]
-> Read RevokeInvitation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevokeInvitation]
$creadListPrec :: ReadPrec [RevokeInvitation]
readPrec :: ReadPrec RevokeInvitation
$creadPrec :: ReadPrec RevokeInvitation
readList :: ReadS [RevokeInvitation]
$creadList :: ReadS [RevokeInvitation]
readsPrec :: Int -> ReadS RevokeInvitation
$creadsPrec :: Int -> ReadS RevokeInvitation
Prelude.Read, Int -> RevokeInvitation -> ShowS
[RevokeInvitation] -> ShowS
RevokeInvitation -> String
(Int -> RevokeInvitation -> ShowS)
-> (RevokeInvitation -> String)
-> ([RevokeInvitation] -> ShowS)
-> Show RevokeInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevokeInvitation] -> ShowS
$cshowList :: [RevokeInvitation] -> ShowS
show :: RevokeInvitation -> String
$cshow :: RevokeInvitation -> String
showsPrec :: Int -> RevokeInvitation -> ShowS
$cshowsPrec :: Int -> RevokeInvitation -> ShowS
Prelude.Show, (forall x. RevokeInvitation -> Rep RevokeInvitation x)
-> (forall x. Rep RevokeInvitation x -> RevokeInvitation)
-> Generic RevokeInvitation
forall x. Rep RevokeInvitation x -> RevokeInvitation
forall x. RevokeInvitation -> Rep RevokeInvitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevokeInvitation x -> RevokeInvitation
$cfrom :: forall x. RevokeInvitation -> Rep RevokeInvitation x
Prelude.Generic)

-- |
-- Create a value of 'RevokeInvitation' 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:
--
-- 'enrollmentId', 'revokeInvitation_enrollmentId' - The ARN of the enrollment invitation to revoke. Required.
--
-- 'userArn', 'revokeInvitation_userArn' - The ARN of the user for whom to revoke an enrollment invitation.
-- Required.
newRevokeInvitation ::
  RevokeInvitation
newRevokeInvitation :: RevokeInvitation
newRevokeInvitation =
  RevokeInvitation' :: Maybe Text -> Maybe Text -> RevokeInvitation
RevokeInvitation'
    { $sel:enrollmentId:RevokeInvitation' :: Maybe Text
enrollmentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userArn:RevokeInvitation' :: Maybe Text
userArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the enrollment invitation to revoke. Required.
revokeInvitation_enrollmentId :: Lens.Lens' RevokeInvitation (Prelude.Maybe Prelude.Text)
revokeInvitation_enrollmentId :: (Maybe Text -> f (Maybe Text))
-> RevokeInvitation -> f RevokeInvitation
revokeInvitation_enrollmentId = (RevokeInvitation -> Maybe Text)
-> (RevokeInvitation -> Maybe Text -> RevokeInvitation)
-> Lens RevokeInvitation RevokeInvitation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeInvitation' {Maybe Text
enrollmentId :: Maybe Text
$sel:enrollmentId:RevokeInvitation' :: RevokeInvitation -> Maybe Text
enrollmentId} -> Maybe Text
enrollmentId) (\s :: RevokeInvitation
s@RevokeInvitation' {} Maybe Text
a -> RevokeInvitation
s {$sel:enrollmentId:RevokeInvitation' :: Maybe Text
enrollmentId = Maybe Text
a} :: RevokeInvitation)

-- | The ARN of the user for whom to revoke an enrollment invitation.
-- Required.
revokeInvitation_userArn :: Lens.Lens' RevokeInvitation (Prelude.Maybe Prelude.Text)
revokeInvitation_userArn :: (Maybe Text -> f (Maybe Text))
-> RevokeInvitation -> f RevokeInvitation
revokeInvitation_userArn = (RevokeInvitation -> Maybe Text)
-> (RevokeInvitation -> Maybe Text -> RevokeInvitation)
-> Lens RevokeInvitation RevokeInvitation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:RevokeInvitation' :: RevokeInvitation -> Maybe Text
userArn} -> Maybe Text
userArn) (\s :: RevokeInvitation
s@RevokeInvitation' {} Maybe Text
a -> RevokeInvitation
s {$sel:userArn:RevokeInvitation' :: Maybe Text
userArn = Maybe Text
a} :: RevokeInvitation)

instance Core.AWSRequest RevokeInvitation where
  type
    AWSResponse RevokeInvitation =
      RevokeInvitationResponse
  request :: RevokeInvitation -> Request RevokeInvitation
request = Service -> RevokeInvitation -> Request RevokeInvitation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RevokeInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RevokeInvitation)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RevokeInvitation))
-> Logger
-> Service
-> Proxy RevokeInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RevokeInvitation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RevokeInvitationResponse
RevokeInvitationResponse'
            (Int -> RevokeInvitationResponse)
-> Either String Int -> Either String RevokeInvitationResponse
forall (f :: * -> *) a b. Functor 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 RevokeInvitation

instance Prelude.NFData RevokeInvitation

instance Core.ToHeaders RevokeInvitation where
  toHeaders :: RevokeInvitation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RevokeInvitation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AlexaForBusiness.RevokeInvitation" ::
                          Prelude.ByteString
                      ),
            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 RevokeInvitation where
  toJSON :: RevokeInvitation -> Value
toJSON RevokeInvitation' {Maybe Text
userArn :: Maybe Text
enrollmentId :: Maybe Text
$sel:userArn:RevokeInvitation' :: RevokeInvitation -> Maybe Text
$sel:enrollmentId:RevokeInvitation' :: RevokeInvitation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnrollmentId" 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
enrollmentId,
            (Text
"UserArn" 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
userArn
          ]
      )

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

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

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

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

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

instance Prelude.NFData RevokeInvitationResponse