{-# 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.Greengrass.DisassociateRoleFromGroup
-- 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)
--
-- Disassociates the role from a group.
module Amazonka.Greengrass.DisassociateRoleFromGroup
  ( -- * Creating a Request
    DisassociateRoleFromGroup (..),
    newDisassociateRoleFromGroup,

    -- * Request Lenses
    disassociateRoleFromGroup_groupId,

    -- * Destructuring the Response
    DisassociateRoleFromGroupResponse (..),
    newDisassociateRoleFromGroupResponse,

    -- * Response Lenses
    disassociateRoleFromGroupResponse_disassociatedAt,
    disassociateRoleFromGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.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:/ 'newDisassociateRoleFromGroup' smart constructor.
data DisassociateRoleFromGroup = DisassociateRoleFromGroup'
  { -- | The ID of the Greengrass group.
    DisassociateRoleFromGroup -> Text
groupId :: Prelude.Text
  }
  deriving (DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool
(DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool)
-> (DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool)
-> Eq DisassociateRoleFromGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool
$c/= :: DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool
== :: DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool
$c== :: DisassociateRoleFromGroup -> DisassociateRoleFromGroup -> Bool
Prelude.Eq, ReadPrec [DisassociateRoleFromGroup]
ReadPrec DisassociateRoleFromGroup
Int -> ReadS DisassociateRoleFromGroup
ReadS [DisassociateRoleFromGroup]
(Int -> ReadS DisassociateRoleFromGroup)
-> ReadS [DisassociateRoleFromGroup]
-> ReadPrec DisassociateRoleFromGroup
-> ReadPrec [DisassociateRoleFromGroup]
-> Read DisassociateRoleFromGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateRoleFromGroup]
$creadListPrec :: ReadPrec [DisassociateRoleFromGroup]
readPrec :: ReadPrec DisassociateRoleFromGroup
$creadPrec :: ReadPrec DisassociateRoleFromGroup
readList :: ReadS [DisassociateRoleFromGroup]
$creadList :: ReadS [DisassociateRoleFromGroup]
readsPrec :: Int -> ReadS DisassociateRoleFromGroup
$creadsPrec :: Int -> ReadS DisassociateRoleFromGroup
Prelude.Read, Int -> DisassociateRoleFromGroup -> ShowS
[DisassociateRoleFromGroup] -> ShowS
DisassociateRoleFromGroup -> String
(Int -> DisassociateRoleFromGroup -> ShowS)
-> (DisassociateRoleFromGroup -> String)
-> ([DisassociateRoleFromGroup] -> ShowS)
-> Show DisassociateRoleFromGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateRoleFromGroup] -> ShowS
$cshowList :: [DisassociateRoleFromGroup] -> ShowS
show :: DisassociateRoleFromGroup -> String
$cshow :: DisassociateRoleFromGroup -> String
showsPrec :: Int -> DisassociateRoleFromGroup -> ShowS
$cshowsPrec :: Int -> DisassociateRoleFromGroup -> ShowS
Prelude.Show, (forall x.
 DisassociateRoleFromGroup -> Rep DisassociateRoleFromGroup x)
-> (forall x.
    Rep DisassociateRoleFromGroup x -> DisassociateRoleFromGroup)
-> Generic DisassociateRoleFromGroup
forall x.
Rep DisassociateRoleFromGroup x -> DisassociateRoleFromGroup
forall x.
DisassociateRoleFromGroup -> Rep DisassociateRoleFromGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateRoleFromGroup x -> DisassociateRoleFromGroup
$cfrom :: forall x.
DisassociateRoleFromGroup -> Rep DisassociateRoleFromGroup x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateRoleFromGroup' 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:
--
-- 'groupId', 'disassociateRoleFromGroup_groupId' - The ID of the Greengrass group.
newDisassociateRoleFromGroup ::
  -- | 'groupId'
  Prelude.Text ->
  DisassociateRoleFromGroup
newDisassociateRoleFromGroup :: Text -> DisassociateRoleFromGroup
newDisassociateRoleFromGroup Text
pGroupId_ =
  DisassociateRoleFromGroup' :: Text -> DisassociateRoleFromGroup
DisassociateRoleFromGroup' {$sel:groupId:DisassociateRoleFromGroup' :: Text
groupId = Text
pGroupId_}

-- | The ID of the Greengrass group.
disassociateRoleFromGroup_groupId :: Lens.Lens' DisassociateRoleFromGroup Prelude.Text
disassociateRoleFromGroup_groupId :: (Text -> f Text)
-> DisassociateRoleFromGroup -> f DisassociateRoleFromGroup
disassociateRoleFromGroup_groupId = (DisassociateRoleFromGroup -> Text)
-> (DisassociateRoleFromGroup -> Text -> DisassociateRoleFromGroup)
-> Lens
     DisassociateRoleFromGroup DisassociateRoleFromGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateRoleFromGroup' {Text
groupId :: Text
$sel:groupId:DisassociateRoleFromGroup' :: DisassociateRoleFromGroup -> Text
groupId} -> Text
groupId) (\s :: DisassociateRoleFromGroup
s@DisassociateRoleFromGroup' {} Text
a -> DisassociateRoleFromGroup
s {$sel:groupId:DisassociateRoleFromGroup' :: Text
groupId = Text
a} :: DisassociateRoleFromGroup)

instance Core.AWSRequest DisassociateRoleFromGroup where
  type
    AWSResponse DisassociateRoleFromGroup =
      DisassociateRoleFromGroupResponse
  request :: DisassociateRoleFromGroup -> Request DisassociateRoleFromGroup
request = Service
-> DisassociateRoleFromGroup -> Request DisassociateRoleFromGroup
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateRoleFromGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateRoleFromGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisassociateRoleFromGroup))
-> Logger
-> Service
-> Proxy DisassociateRoleFromGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateRoleFromGroup)))
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 Text -> Int -> DisassociateRoleFromGroupResponse
DisassociateRoleFromGroupResponse'
            (Maybe Text -> Int -> DisassociateRoleFromGroupResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DisassociateRoleFromGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DisassociatedAt")
            Either String (Int -> DisassociateRoleFromGroupResponse)
-> Either String Int
-> Either String DisassociateRoleFromGroupResponse
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 DisassociateRoleFromGroup

instance Prelude.NFData DisassociateRoleFromGroup

instance Core.ToHeaders DisassociateRoleFromGroup where
  toHeaders :: DisassociateRoleFromGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateRoleFromGroup -> 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.ToPath DisassociateRoleFromGroup where
  toPath :: DisassociateRoleFromGroup -> ByteString
toPath DisassociateRoleFromGroup' {Text
groupId :: Text
$sel:groupId:DisassociateRoleFromGroup' :: DisassociateRoleFromGroup -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/greengrass/groups/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
groupId, ByteString
"/role"]

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

-- | /See:/ 'newDisassociateRoleFromGroupResponse' smart constructor.
data DisassociateRoleFromGroupResponse = DisassociateRoleFromGroupResponse'
  { -- | The time, in milliseconds since the epoch, when the role was
    -- disassociated from the group.
    DisassociateRoleFromGroupResponse -> Maybe Text
disassociatedAt :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DisassociateRoleFromGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisassociateRoleFromGroupResponse
-> DisassociateRoleFromGroupResponse -> Bool
(DisassociateRoleFromGroupResponse
 -> DisassociateRoleFromGroupResponse -> Bool)
-> (DisassociateRoleFromGroupResponse
    -> DisassociateRoleFromGroupResponse -> Bool)
-> Eq DisassociateRoleFromGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateRoleFromGroupResponse
-> DisassociateRoleFromGroupResponse -> Bool
$c/= :: DisassociateRoleFromGroupResponse
-> DisassociateRoleFromGroupResponse -> Bool
== :: DisassociateRoleFromGroupResponse
-> DisassociateRoleFromGroupResponse -> Bool
$c== :: DisassociateRoleFromGroupResponse
-> DisassociateRoleFromGroupResponse -> Bool
Prelude.Eq, ReadPrec [DisassociateRoleFromGroupResponse]
ReadPrec DisassociateRoleFromGroupResponse
Int -> ReadS DisassociateRoleFromGroupResponse
ReadS [DisassociateRoleFromGroupResponse]
(Int -> ReadS DisassociateRoleFromGroupResponse)
-> ReadS [DisassociateRoleFromGroupResponse]
-> ReadPrec DisassociateRoleFromGroupResponse
-> ReadPrec [DisassociateRoleFromGroupResponse]
-> Read DisassociateRoleFromGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateRoleFromGroupResponse]
$creadListPrec :: ReadPrec [DisassociateRoleFromGroupResponse]
readPrec :: ReadPrec DisassociateRoleFromGroupResponse
$creadPrec :: ReadPrec DisassociateRoleFromGroupResponse
readList :: ReadS [DisassociateRoleFromGroupResponse]
$creadList :: ReadS [DisassociateRoleFromGroupResponse]
readsPrec :: Int -> ReadS DisassociateRoleFromGroupResponse
$creadsPrec :: Int -> ReadS DisassociateRoleFromGroupResponse
Prelude.Read, Int -> DisassociateRoleFromGroupResponse -> ShowS
[DisassociateRoleFromGroupResponse] -> ShowS
DisassociateRoleFromGroupResponse -> String
(Int -> DisassociateRoleFromGroupResponse -> ShowS)
-> (DisassociateRoleFromGroupResponse -> String)
-> ([DisassociateRoleFromGroupResponse] -> ShowS)
-> Show DisassociateRoleFromGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateRoleFromGroupResponse] -> ShowS
$cshowList :: [DisassociateRoleFromGroupResponse] -> ShowS
show :: DisassociateRoleFromGroupResponse -> String
$cshow :: DisassociateRoleFromGroupResponse -> String
showsPrec :: Int -> DisassociateRoleFromGroupResponse -> ShowS
$cshowsPrec :: Int -> DisassociateRoleFromGroupResponse -> ShowS
Prelude.Show, (forall x.
 DisassociateRoleFromGroupResponse
 -> Rep DisassociateRoleFromGroupResponse x)
-> (forall x.
    Rep DisassociateRoleFromGroupResponse x
    -> DisassociateRoleFromGroupResponse)
-> Generic DisassociateRoleFromGroupResponse
forall x.
Rep DisassociateRoleFromGroupResponse x
-> DisassociateRoleFromGroupResponse
forall x.
DisassociateRoleFromGroupResponse
-> Rep DisassociateRoleFromGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateRoleFromGroupResponse x
-> DisassociateRoleFromGroupResponse
$cfrom :: forall x.
DisassociateRoleFromGroupResponse
-> Rep DisassociateRoleFromGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateRoleFromGroupResponse' 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:
--
-- 'disassociatedAt', 'disassociateRoleFromGroupResponse_disassociatedAt' - The time, in milliseconds since the epoch, when the role was
-- disassociated from the group.
--
-- 'httpStatus', 'disassociateRoleFromGroupResponse_httpStatus' - The response's http status code.
newDisassociateRoleFromGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateRoleFromGroupResponse
newDisassociateRoleFromGroupResponse :: Int -> DisassociateRoleFromGroupResponse
newDisassociateRoleFromGroupResponse Int
pHttpStatus_ =
  DisassociateRoleFromGroupResponse' :: Maybe Text -> Int -> DisassociateRoleFromGroupResponse
DisassociateRoleFromGroupResponse'
    { $sel:disassociatedAt:DisassociateRoleFromGroupResponse' :: Maybe Text
disassociatedAt =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateRoleFromGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The time, in milliseconds since the epoch, when the role was
-- disassociated from the group.
disassociateRoleFromGroupResponse_disassociatedAt :: Lens.Lens' DisassociateRoleFromGroupResponse (Prelude.Maybe Prelude.Text)
disassociateRoleFromGroupResponse_disassociatedAt :: (Maybe Text -> f (Maybe Text))
-> DisassociateRoleFromGroupResponse
-> f DisassociateRoleFromGroupResponse
disassociateRoleFromGroupResponse_disassociatedAt = (DisassociateRoleFromGroupResponse -> Maybe Text)
-> (DisassociateRoleFromGroupResponse
    -> Maybe Text -> DisassociateRoleFromGroupResponse)
-> Lens
     DisassociateRoleFromGroupResponse
     DisassociateRoleFromGroupResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateRoleFromGroupResponse' {Maybe Text
disassociatedAt :: Maybe Text
$sel:disassociatedAt:DisassociateRoleFromGroupResponse' :: DisassociateRoleFromGroupResponse -> Maybe Text
disassociatedAt} -> Maybe Text
disassociatedAt) (\s :: DisassociateRoleFromGroupResponse
s@DisassociateRoleFromGroupResponse' {} Maybe Text
a -> DisassociateRoleFromGroupResponse
s {$sel:disassociatedAt:DisassociateRoleFromGroupResponse' :: Maybe Text
disassociatedAt = Maybe Text
a} :: DisassociateRoleFromGroupResponse)

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

instance
  Prelude.NFData
    DisassociateRoleFromGroupResponse