{-# 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.ManagedBlockChain.DeleteMember
-- 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)
--
-- Deletes a member. Deleting a member removes the member and all
-- associated resources from the network. @DeleteMember@ can only be called
-- for a specified @MemberId@ if the principal performing the action is
-- associated with the AWS account that owns the member. In all other
-- cases, the @DeleteMember@ action is carried out as the result of an
-- approved proposal to remove a member. If @MemberId@ is the last member
-- in a network specified by the last AWS account, the network is deleted
-- also.
--
-- Applies only to Hyperledger Fabric.
module Amazonka.ManagedBlockChain.DeleteMember
  ( -- * Creating a Request
    DeleteMember (..),
    newDeleteMember,

    -- * Request Lenses
    deleteMember_networkId,
    deleteMember_memberId,

    -- * Destructuring the Response
    DeleteMemberResponse (..),
    newDeleteMemberResponse,

    -- * Response Lenses
    deleteMemberResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteMember' smart constructor.
data DeleteMember = DeleteMember'
  { -- | The unique identifier of the network from which the member is removed.
    DeleteMember -> Text
networkId :: Prelude.Text,
    -- | The unique identifier of the member to remove.
    DeleteMember -> Text
memberId :: Prelude.Text
  }
  deriving (DeleteMember -> DeleteMember -> Bool
(DeleteMember -> DeleteMember -> Bool)
-> (DeleteMember -> DeleteMember -> Bool) -> Eq DeleteMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMember -> DeleteMember -> Bool
$c/= :: DeleteMember -> DeleteMember -> Bool
== :: DeleteMember -> DeleteMember -> Bool
$c== :: DeleteMember -> DeleteMember -> Bool
Prelude.Eq, ReadPrec [DeleteMember]
ReadPrec DeleteMember
Int -> ReadS DeleteMember
ReadS [DeleteMember]
(Int -> ReadS DeleteMember)
-> ReadS [DeleteMember]
-> ReadPrec DeleteMember
-> ReadPrec [DeleteMember]
-> Read DeleteMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMember]
$creadListPrec :: ReadPrec [DeleteMember]
readPrec :: ReadPrec DeleteMember
$creadPrec :: ReadPrec DeleteMember
readList :: ReadS [DeleteMember]
$creadList :: ReadS [DeleteMember]
readsPrec :: Int -> ReadS DeleteMember
$creadsPrec :: Int -> ReadS DeleteMember
Prelude.Read, Int -> DeleteMember -> ShowS
[DeleteMember] -> ShowS
DeleteMember -> String
(Int -> DeleteMember -> ShowS)
-> (DeleteMember -> String)
-> ([DeleteMember] -> ShowS)
-> Show DeleteMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMember] -> ShowS
$cshowList :: [DeleteMember] -> ShowS
show :: DeleteMember -> String
$cshow :: DeleteMember -> String
showsPrec :: Int -> DeleteMember -> ShowS
$cshowsPrec :: Int -> DeleteMember -> ShowS
Prelude.Show, (forall x. DeleteMember -> Rep DeleteMember x)
-> (forall x. Rep DeleteMember x -> DeleteMember)
-> Generic DeleteMember
forall x. Rep DeleteMember x -> DeleteMember
forall x. DeleteMember -> Rep DeleteMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteMember x -> DeleteMember
$cfrom :: forall x. DeleteMember -> Rep DeleteMember x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMember' 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:
--
-- 'networkId', 'deleteMember_networkId' - The unique identifier of the network from which the member is removed.
--
-- 'memberId', 'deleteMember_memberId' - The unique identifier of the member to remove.
newDeleteMember ::
  -- | 'networkId'
  Prelude.Text ->
  -- | 'memberId'
  Prelude.Text ->
  DeleteMember
newDeleteMember :: Text -> Text -> DeleteMember
newDeleteMember Text
pNetworkId_ Text
pMemberId_ =
  DeleteMember' :: Text -> Text -> DeleteMember
DeleteMember'
    { $sel:networkId:DeleteMember' :: Text
networkId = Text
pNetworkId_,
      $sel:memberId:DeleteMember' :: Text
memberId = Text
pMemberId_
    }

-- | The unique identifier of the network from which the member is removed.
deleteMember_networkId :: Lens.Lens' DeleteMember Prelude.Text
deleteMember_networkId :: (Text -> f Text) -> DeleteMember -> f DeleteMember
deleteMember_networkId = (DeleteMember -> Text)
-> (DeleteMember -> Text -> DeleteMember)
-> Lens DeleteMember DeleteMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMember' {Text
networkId :: Text
$sel:networkId:DeleteMember' :: DeleteMember -> Text
networkId} -> Text
networkId) (\s :: DeleteMember
s@DeleteMember' {} Text
a -> DeleteMember
s {$sel:networkId:DeleteMember' :: Text
networkId = Text
a} :: DeleteMember)

-- | The unique identifier of the member to remove.
deleteMember_memberId :: Lens.Lens' DeleteMember Prelude.Text
deleteMember_memberId :: (Text -> f Text) -> DeleteMember -> f DeleteMember
deleteMember_memberId = (DeleteMember -> Text)
-> (DeleteMember -> Text -> DeleteMember)
-> Lens DeleteMember DeleteMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMember' {Text
memberId :: Text
$sel:memberId:DeleteMember' :: DeleteMember -> Text
memberId} -> Text
memberId) (\s :: DeleteMember
s@DeleteMember' {} Text
a -> DeleteMember
s {$sel:memberId:DeleteMember' :: Text
memberId = Text
a} :: DeleteMember)

instance Core.AWSRequest DeleteMember where
  type AWSResponse DeleteMember = DeleteMemberResponse
  request :: DeleteMember -> Request DeleteMember
request = Service -> DeleteMember -> Request DeleteMember
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMember
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMember)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteMember))
-> Logger
-> Service
-> Proxy DeleteMember
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMember)))
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 -> DeleteMemberResponse
DeleteMemberResponse'
            (Int -> DeleteMemberResponse)
-> Either String Int -> Either String DeleteMemberResponse
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 DeleteMember

instance Prelude.NFData DeleteMember

instance Core.ToHeaders DeleteMember where
  toHeaders :: DeleteMember -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMember -> 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 DeleteMember where
  toPath :: DeleteMember -> ByteString
toPath DeleteMember' {Text
memberId :: Text
networkId :: Text
$sel:memberId:DeleteMember' :: DeleteMember -> Text
$sel:networkId:DeleteMember' :: DeleteMember -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/networks/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
networkId,
        ByteString
"/members/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
memberId
      ]

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

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

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

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

instance Prelude.NFData DeleteMemberResponse