{-# 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.ServiceCatalogAppRegistry.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)
--
-- Disassociates a resource from application. Both the resource and the
-- application can be specified either by ID or name.
module Amazonka.ServiceCatalogAppRegistry.DisassociateResource
  ( -- * Creating a Request
    DisassociateResource (..),
    newDisassociateResource,

    -- * Request Lenses
    disassociateResource_application,
    disassociateResource_resourceType,
    disassociateResource_resource,

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

    -- * Response Lenses
    disassociateResourceResponse_applicationArn,
    disassociateResourceResponse_resourceArn,
    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.ServiceCatalogAppRegistry.Types

-- | /See:/ 'newDisassociateResource' smart constructor.
data DisassociateResource = DisassociateResource'
  { -- | The name or ID of the application.
    DisassociateResource -> Text
application :: Prelude.Text,
    -- | The type of the resource that is being disassociated.
    DisassociateResource -> ResourceType
resourceType :: ResourceType,
    -- | The name or ID of the resource.
    DisassociateResource -> Text
resource :: 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:
--
-- 'application', 'disassociateResource_application' - The name or ID of the application.
--
-- 'resourceType', 'disassociateResource_resourceType' - The type of the resource that is being disassociated.
--
-- 'resource', 'disassociateResource_resource' - The name or ID of the resource.
newDisassociateResource ::
  -- | 'application'
  Prelude.Text ->
  -- | 'resourceType'
  ResourceType ->
  -- | 'resource'
  Prelude.Text ->
  DisassociateResource
newDisassociateResource :: Text -> ResourceType -> Text -> DisassociateResource
newDisassociateResource
  Text
pApplication_
  ResourceType
pResourceType_
  Text
pResource_ =
    DisassociateResource'
      { $sel:application:DisassociateResource' :: Text
application = Text
pApplication_,
        $sel:resourceType:DisassociateResource' :: ResourceType
resourceType = ResourceType
pResourceType_,
        $sel:resource:DisassociateResource' :: Text
resource = Text
pResource_
      }

-- | The name or ID of the application.
disassociateResource_application :: Lens.Lens' DisassociateResource Prelude.Text
disassociateResource_application :: Lens' DisassociateResource Text
disassociateResource_application = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResource' {Text
application :: Text
$sel:application:DisassociateResource' :: DisassociateResource -> Text
application} -> Text
application) (\s :: DisassociateResource
s@DisassociateResource' {} Text
a -> DisassociateResource
s {$sel:application:DisassociateResource' :: Text
application = Text
a} :: DisassociateResource)

-- | The type of the resource that is being disassociated.
disassociateResource_resourceType :: Lens.Lens' DisassociateResource ResourceType
disassociateResource_resourceType :: Lens' DisassociateResource ResourceType
disassociateResource_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResource' {ResourceType
resourceType :: ResourceType
$sel:resourceType:DisassociateResource' :: DisassociateResource -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: DisassociateResource
s@DisassociateResource' {} ResourceType
a -> DisassociateResource
s {$sel:resourceType:DisassociateResource' :: ResourceType
resourceType = ResourceType
a} :: DisassociateResource)

-- | The name or ID of the resource.
disassociateResource_resource :: Lens.Lens' DisassociateResource Prelude.Text
disassociateResource_resource :: Lens' DisassociateResource Text
disassociateResource_resource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResource' {Text
resource :: Text
$sel:resource:DisassociateResource' :: DisassociateResource -> Text
resource} -> Text
resource) (\s :: DisassociateResource
s@DisassociateResource' {} Text
a -> DisassociateResource
s {$sel:resource:DisassociateResource' :: Text
resource = 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 => Service -> a -> Request a
Request.delete (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 -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> DisassociateResourceResponse
DisassociateResourceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"applicationArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"resourceArn")
            forall (f :: * -> *) a b. Applicative f => 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
ResourceType
resource :: Text
resourceType :: ResourceType
application :: Text
$sel:resource:DisassociateResource' :: DisassociateResource -> Text
$sel:resourceType:DisassociateResource' :: DisassociateResource -> ResourceType
$sel:application:DisassociateResource' :: DisassociateResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
application
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resource

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

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.ToPath DisassociateResource where
  toPath :: DisassociateResource -> ByteString
toPath DisassociateResource' {Text
ResourceType
resource :: Text
resourceType :: ResourceType
application :: Text
$sel:resource:DisassociateResource' :: DisassociateResource -> Text
$sel:resourceType:DisassociateResource' :: DisassociateResource -> ResourceType
$sel:application:DisassociateResource' :: DisassociateResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
application,
        ByteString
"/resources/",
        forall a. ToByteString a => a -> ByteString
Data.toBS ResourceType
resourceType,
        ByteString
"/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
resource
      ]

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 Amazon resource name (ARN) that specifies the application.
    DisassociateResourceResponse -> Maybe Text
applicationArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon resource name (ARN) that specifies the resource.
    DisassociateResourceResponse -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | 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:
--
-- 'applicationArn', 'disassociateResourceResponse_applicationArn' - The Amazon resource name (ARN) that specifies the application.
--
-- 'resourceArn', 'disassociateResourceResponse_resourceArn' - The Amazon resource name (ARN) that specifies the resource.
--
-- 'httpStatus', 'disassociateResourceResponse_httpStatus' - The response's http status code.
newDisassociateResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateResourceResponse
newDisassociateResourceResponse :: Int -> DisassociateResourceResponse
newDisassociateResourceResponse Int
pHttpStatus_ =
  DisassociateResourceResponse'
    { $sel:applicationArn:DisassociateResourceResponse' :: Maybe Text
applicationArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:DisassociateResourceResponse' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon resource name (ARN) that specifies the application.
disassociateResourceResponse_applicationArn :: Lens.Lens' DisassociateResourceResponse (Prelude.Maybe Prelude.Text)
disassociateResourceResponse_applicationArn :: Lens' DisassociateResourceResponse (Maybe Text)
disassociateResourceResponse_applicationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResourceResponse' {Maybe Text
applicationArn :: Maybe Text
$sel:applicationArn:DisassociateResourceResponse' :: DisassociateResourceResponse -> Maybe Text
applicationArn} -> Maybe Text
applicationArn) (\s :: DisassociateResourceResponse
s@DisassociateResourceResponse' {} Maybe Text
a -> DisassociateResourceResponse
s {$sel:applicationArn:DisassociateResourceResponse' :: Maybe Text
applicationArn = Maybe Text
a} :: DisassociateResourceResponse)

-- | The Amazon resource name (ARN) that specifies the resource.
disassociateResourceResponse_resourceArn :: Lens.Lens' DisassociateResourceResponse (Prelude.Maybe Prelude.Text)
disassociateResourceResponse_resourceArn :: Lens' DisassociateResourceResponse (Maybe Text)
disassociateResourceResponse_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResourceResponse' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:DisassociateResourceResponse' :: DisassociateResourceResponse -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: DisassociateResourceResponse
s@DisassociateResourceResponse' {} Maybe Text
a -> DisassociateResourceResponse
s {$sel:resourceArn:DisassociateResourceResponse' :: Maybe Text
resourceArn = Maybe Text
a} :: DisassociateResourceResponse)

-- | 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
Maybe Text
httpStatus :: Int
resourceArn :: Maybe Text
applicationArn :: Maybe Text
$sel:httpStatus:DisassociateResourceResponse' :: DisassociateResourceResponse -> Int
$sel:resourceArn:DisassociateResourceResponse' :: DisassociateResourceResponse -> Maybe Text
$sel:applicationArn:DisassociateResourceResponse' :: DisassociateResourceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
applicationArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus