{-# 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-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 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.Lens as Lens
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
(DisassociateResource -> DisassociateResource -> Bool)
-> (DisassociateResource -> DisassociateResource -> Bool)
-> Eq DisassociateResource
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]
(Int -> ReadS DisassociateResource)
-> ReadS [DisassociateResource]
-> ReadPrec DisassociateResource
-> ReadPrec [DisassociateResource]
-> Read 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
(Int -> DisassociateResource -> ShowS)
-> (DisassociateResource -> String)
-> ([DisassociateResource] -> ShowS)
-> Show DisassociateResource
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. DisassociateResource -> Rep DisassociateResource x)
-> (forall x. Rep DisassociateResource x -> DisassociateResource)
-> Generic DisassociateResource
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' :: Text -> ResourceType -> Text -> DisassociateResource
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 :: (Text -> f Text) -> DisassociateResource -> f DisassociateResource
disassociateResource_application = (DisassociateResource -> Text)
-> (DisassociateResource -> Text -> DisassociateResource)
-> Lens DisassociateResource DisassociateResource Text Text
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 :: (ResourceType -> f ResourceType)
-> DisassociateResource -> f DisassociateResource
disassociateResource_resourceType = (DisassociateResource -> ResourceType)
-> (DisassociateResource -> ResourceType -> DisassociateResource)
-> Lens
     DisassociateResource DisassociateResource ResourceType 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 :: (Text -> f Text) -> DisassociateResource -> f DisassociateResource
disassociateResource_resource = (DisassociateResource -> Text)
-> (DisassociateResource -> Text -> DisassociateResource)
-> Lens DisassociateResource DisassociateResource Text Text
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 :: DisassociateResource -> Request DisassociateResource
request = Service -> DisassociateResource -> Request DisassociateResource
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateResource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisassociateResource))
-> Logger
-> Service
-> Proxy DisassociateResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateResource)))
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 -> Maybe Text -> Int -> DisassociateResourceResponse
DisassociateResourceResponse'
            (Maybe Text -> Maybe Text -> Int -> DisassociateResourceResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> DisassociateResourceResponse)
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
"applicationArn")
            Either String (Maybe Text -> Int -> DisassociateResourceResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DisassociateResourceResponse)
forall (f :: * -> *) a b. Applicative f => 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
"resourceArn")
            Either String (Int -> DisassociateResourceResponse)
-> Either String Int -> Either String DisassociateResourceResponse
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 DisassociateResource

instance Prelude.NFData DisassociateResource

instance Core.ToHeaders DisassociateResource where
  toHeaders :: DisassociateResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateResource -> 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 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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
application,
        ByteString
"/resources/",
        ResourceType -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS ResourceType
resourceType,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resource
      ]

instance Core.ToQuery DisassociateResource where
  toQuery :: DisassociateResource -> QueryString
toQuery = QueryString -> DisassociateResource -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DisassociateResourceResponse
 -> DisassociateResourceResponse -> Bool)
-> (DisassociateResourceResponse
    -> DisassociateResourceResponse -> Bool)
-> Eq DisassociateResourceResponse
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]
(Int -> ReadS DisassociateResourceResponse)
-> ReadS [DisassociateResourceResponse]
-> ReadPrec DisassociateResourceResponse
-> ReadPrec [DisassociateResourceResponse]
-> Read 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
(Int -> DisassociateResourceResponse -> ShowS)
-> (DisassociateResourceResponse -> String)
-> ([DisassociateResourceResponse] -> ShowS)
-> Show DisassociateResourceResponse
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.
 DisassociateResourceResponse -> Rep DisassociateResourceResponse x)
-> (forall x.
    Rep DisassociateResourceResponse x -> DisassociateResourceResponse)
-> Generic DisassociateResourceResponse
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' :: Maybe Text -> Maybe Text -> Int -> DisassociateResourceResponse
DisassociateResourceResponse'
    { $sel:applicationArn:DisassociateResourceResponse' :: Maybe Text
applicationArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:DisassociateResourceResponse' :: Maybe Text
resourceArn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DisassociateResourceResponse -> f DisassociateResourceResponse
disassociateResourceResponse_applicationArn = (DisassociateResourceResponse -> Maybe Text)
-> (DisassociateResourceResponse
    -> Maybe Text -> DisassociateResourceResponse)
-> Lens
     DisassociateResourceResponse
     DisassociateResourceResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> DisassociateResourceResponse -> f DisassociateResourceResponse
disassociateResourceResponse_resourceArn = (DisassociateResourceResponse -> Maybe Text)
-> (DisassociateResourceResponse
    -> Maybe Text -> DisassociateResourceResponse)
-> Lens
     DisassociateResourceResponse
     DisassociateResourceResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> DisassociateResourceResponse -> f DisassociateResourceResponse
disassociateResourceResponse_httpStatus = (DisassociateResourceResponse -> Int)
-> (DisassociateResourceResponse
    -> Int -> DisassociateResourceResponse)
-> Lens
     DisassociateResourceResponse DisassociateResourceResponse Int Int
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