{-# 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.Synthetics.DisassociateResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes a canary from a group. You must run this operation in the Region
-- where the canary exists.
module Amazonka.Synthetics.DisassociateResource
  ( -- * Creating a Request
    DisassociateResource (..),
    newDisassociateResource,

    -- * Request Lenses
    disassociateResource_groupIdentifier,
    disassociateResource_resourceArn,

    -- * Destructuring the Response
    DisassociateResourceResponse (..),
    newDisassociateResourceResponse,

    -- * Response Lenses
    disassociateResourceResponse_httpStatus,
  )
where

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
import Amazonka.Synthetics.Types

-- | /See:/ 'newDisassociateResource' smart constructor.
data DisassociateResource = DisassociateResource'
  { -- | Specifies the group. You can specify the group name, the ARN, or the
    -- group ID as the @GroupIdentifier@.
    DisassociateResource -> Text
groupIdentifier :: Prelude.Text,
    -- | The ARN of the canary that you want to remove from the specified group.
    DisassociateResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (DisassociateResource -> DisassociateResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateResource -> DisassociateResource -> Bool
$c/= :: DisassociateResource -> DisassociateResource -> Bool
== :: DisassociateResource -> DisassociateResource -> Bool
$c== :: DisassociateResource -> DisassociateResource -> Bool
Prelude.Eq, ReadPrec [DisassociateResource]
ReadPrec DisassociateResource
Int -> ReadS DisassociateResource
ReadS [DisassociateResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateResource]
$creadListPrec :: ReadPrec [DisassociateResource]
readPrec :: ReadPrec DisassociateResource
$creadPrec :: ReadPrec DisassociateResource
readList :: ReadS [DisassociateResource]
$creadList :: ReadS [DisassociateResource]
readsPrec :: Int -> ReadS DisassociateResource
$creadsPrec :: Int -> ReadS DisassociateResource
Prelude.Read, Int -> DisassociateResource -> ShowS
[DisassociateResource] -> ShowS
DisassociateResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateResource] -> ShowS
$cshowList :: [DisassociateResource] -> ShowS
show :: DisassociateResource -> String
$cshow :: DisassociateResource -> String
showsPrec :: Int -> DisassociateResource -> ShowS
$cshowsPrec :: Int -> DisassociateResource -> ShowS
Prelude.Show, forall x. Rep DisassociateResource x -> DisassociateResource
forall x. DisassociateResource -> Rep DisassociateResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateResource x -> DisassociateResource
$cfrom :: forall x. DisassociateResource -> Rep DisassociateResource x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateResource' 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:
--
-- 'groupIdentifier', 'disassociateResource_groupIdentifier' - Specifies the group. You can specify the group name, the ARN, or the
-- group ID as the @GroupIdentifier@.
--
-- 'resourceArn', 'disassociateResource_resourceArn' - The ARN of the canary that you want to remove from the specified group.
newDisassociateResource ::
  -- | 'groupIdentifier'
  Prelude.Text ->
  -- | 'resourceArn'
  Prelude.Text ->
  DisassociateResource
newDisassociateResource :: Text -> Text -> DisassociateResource
newDisassociateResource
  Text
pGroupIdentifier_
  Text
pResourceArn_ =
    DisassociateResource'
      { $sel:groupIdentifier:DisassociateResource' :: Text
groupIdentifier =
          Text
pGroupIdentifier_,
        $sel:resourceArn:DisassociateResource' :: Text
resourceArn = Text
pResourceArn_
      }

-- | Specifies the group. You can specify the group name, the ARN, or the
-- group ID as the @GroupIdentifier@.
disassociateResource_groupIdentifier :: Lens.Lens' DisassociateResource Prelude.Text
disassociateResource_groupIdentifier :: Lens' DisassociateResource Text
disassociateResource_groupIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResource' {Text
groupIdentifier :: Text
$sel:groupIdentifier:DisassociateResource' :: DisassociateResource -> Text
groupIdentifier} -> Text
groupIdentifier) (\s :: DisassociateResource
s@DisassociateResource' {} Text
a -> DisassociateResource
s {$sel:groupIdentifier:DisassociateResource' :: Text
groupIdentifier = Text
a} :: DisassociateResource)

-- | The ARN of the canary that you want to remove from the specified group.
disassociateResource_resourceArn :: Lens.Lens' DisassociateResource Prelude.Text
disassociateResource_resourceArn :: Lens' DisassociateResource Text
disassociateResource_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResource' {Text
resourceArn :: Text
$sel:resourceArn:DisassociateResource' :: DisassociateResource -> Text
resourceArn} -> Text
resourceArn) (\s :: DisassociateResource
s@DisassociateResource' {} Text
a -> DisassociateResource
s {$sel:resourceArn:DisassociateResource' :: Text
resourceArn = Text
a} :: DisassociateResource)

instance Core.AWSRequest DisassociateResource where
  type
    AWSResponse DisassociateResource =
      DisassociateResourceResponse
  request :: (Service -> Service)
-> DisassociateResource -> Request DisassociateResource
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisassociateResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateResource)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DisassociateResourceResponse
DisassociateResourceResponse'
            forall (f :: * -> *) a b. Functor 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 DisassociateResource where
  hashWithSalt :: Int -> DisassociateResource -> Int
hashWithSalt Int
_salt DisassociateResource' {Text
resourceArn :: Text
groupIdentifier :: Text
$sel:resourceArn:DisassociateResource' :: DisassociateResource -> Text
$sel:groupIdentifier:DisassociateResource' :: DisassociateResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData DisassociateResource where
  rnf :: DisassociateResource -> ()
rnf DisassociateResource' {Text
resourceArn :: Text
groupIdentifier :: Text
$sel:resourceArn:DisassociateResource' :: DisassociateResource -> Text
$sel:groupIdentifier:DisassociateResource' :: DisassociateResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
groupIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders DisassociateResource where
  toHeaders :: DisassociateResource -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DisassociateResource where
  toJSON :: DisassociateResource -> Value
toJSON DisassociateResource' {Text
resourceArn :: Text
groupIdentifier :: Text
$sel:resourceArn:DisassociateResource' :: DisassociateResource -> Text
$sel:groupIdentifier:DisassociateResource' :: DisassociateResource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ResourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceArn)]
      )

instance Data.ToPath DisassociateResource where
  toPath :: DisassociateResource -> ByteString
toPath DisassociateResource' {Text
resourceArn :: Text
groupIdentifier :: Text
$sel:resourceArn:DisassociateResource' :: DisassociateResource -> Text
$sel:groupIdentifier:DisassociateResource' :: DisassociateResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/group/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
groupIdentifier,
        ByteString
"/disassociate"
      ]

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

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

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

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

instance Prelude.NFData DisassociateResourceResponse where
  rnf :: DisassociateResourceResponse -> ()
rnf DisassociateResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:DisassociateResourceResponse' :: DisassociateResourceResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus