{-# 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.GetAssociatedResource
-- 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)
--
-- Gets the resource associated with the application.
module Amazonka.ServiceCatalogAppRegistry.GetAssociatedResource
  ( -- * Creating a Request
    GetAssociatedResource (..),
    newGetAssociatedResource,

    -- * Request Lenses
    getAssociatedResource_application,
    getAssociatedResource_resourceType,
    getAssociatedResource_resource,

    -- * Destructuring the Response
    GetAssociatedResourceResponse (..),
    newGetAssociatedResourceResponse,

    -- * Response Lenses
    getAssociatedResourceResponse_resource,
    getAssociatedResourceResponse_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:/ 'newGetAssociatedResource' smart constructor.
data GetAssociatedResource = GetAssociatedResource'
  { -- | The name or ID of the application.
    GetAssociatedResource -> Text
application :: Prelude.Text,
    -- | The type of resource associated with the application.
    GetAssociatedResource -> ResourceType
resourceType :: ResourceType,
    -- | The name or ID of the resource associated with the application.
    GetAssociatedResource -> Text
resource :: Prelude.Text
  }
  deriving (GetAssociatedResource -> GetAssociatedResource -> Bool
(GetAssociatedResource -> GetAssociatedResource -> Bool)
-> (GetAssociatedResource -> GetAssociatedResource -> Bool)
-> Eq GetAssociatedResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAssociatedResource -> GetAssociatedResource -> Bool
$c/= :: GetAssociatedResource -> GetAssociatedResource -> Bool
== :: GetAssociatedResource -> GetAssociatedResource -> Bool
$c== :: GetAssociatedResource -> GetAssociatedResource -> Bool
Prelude.Eq, ReadPrec [GetAssociatedResource]
ReadPrec GetAssociatedResource
Int -> ReadS GetAssociatedResource
ReadS [GetAssociatedResource]
(Int -> ReadS GetAssociatedResource)
-> ReadS [GetAssociatedResource]
-> ReadPrec GetAssociatedResource
-> ReadPrec [GetAssociatedResource]
-> Read GetAssociatedResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAssociatedResource]
$creadListPrec :: ReadPrec [GetAssociatedResource]
readPrec :: ReadPrec GetAssociatedResource
$creadPrec :: ReadPrec GetAssociatedResource
readList :: ReadS [GetAssociatedResource]
$creadList :: ReadS [GetAssociatedResource]
readsPrec :: Int -> ReadS GetAssociatedResource
$creadsPrec :: Int -> ReadS GetAssociatedResource
Prelude.Read, Int -> GetAssociatedResource -> ShowS
[GetAssociatedResource] -> ShowS
GetAssociatedResource -> String
(Int -> GetAssociatedResource -> ShowS)
-> (GetAssociatedResource -> String)
-> ([GetAssociatedResource] -> ShowS)
-> Show GetAssociatedResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAssociatedResource] -> ShowS
$cshowList :: [GetAssociatedResource] -> ShowS
show :: GetAssociatedResource -> String
$cshow :: GetAssociatedResource -> String
showsPrec :: Int -> GetAssociatedResource -> ShowS
$cshowsPrec :: Int -> GetAssociatedResource -> ShowS
Prelude.Show, (forall x. GetAssociatedResource -> Rep GetAssociatedResource x)
-> (forall x. Rep GetAssociatedResource x -> GetAssociatedResource)
-> Generic GetAssociatedResource
forall x. Rep GetAssociatedResource x -> GetAssociatedResource
forall x. GetAssociatedResource -> Rep GetAssociatedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAssociatedResource x -> GetAssociatedResource
$cfrom :: forall x. GetAssociatedResource -> Rep GetAssociatedResource x
Prelude.Generic)

-- |
-- Create a value of 'GetAssociatedResource' 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', 'getAssociatedResource_application' - The name or ID of the application.
--
-- 'resourceType', 'getAssociatedResource_resourceType' - The type of resource associated with the application.
--
-- 'resource', 'getAssociatedResource_resource' - The name or ID of the resource associated with the application.
newGetAssociatedResource ::
  -- | 'application'
  Prelude.Text ->
  -- | 'resourceType'
  ResourceType ->
  -- | 'resource'
  Prelude.Text ->
  GetAssociatedResource
newGetAssociatedResource :: Text -> ResourceType -> Text -> GetAssociatedResource
newGetAssociatedResource
  Text
pApplication_
  ResourceType
pResourceType_
  Text
pResource_ =
    GetAssociatedResource' :: Text -> ResourceType -> Text -> GetAssociatedResource
GetAssociatedResource'
      { $sel:application:GetAssociatedResource' :: Text
application = Text
pApplication_,
        $sel:resourceType:GetAssociatedResource' :: ResourceType
resourceType = ResourceType
pResourceType_,
        $sel:resource:GetAssociatedResource' :: Text
resource = Text
pResource_
      }

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

-- | The type of resource associated with the application.
getAssociatedResource_resourceType :: Lens.Lens' GetAssociatedResource ResourceType
getAssociatedResource_resourceType :: (ResourceType -> f ResourceType)
-> GetAssociatedResource -> f GetAssociatedResource
getAssociatedResource_resourceType = (GetAssociatedResource -> ResourceType)
-> (GetAssociatedResource -> ResourceType -> GetAssociatedResource)
-> Lens
     GetAssociatedResource
     GetAssociatedResource
     ResourceType
     ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssociatedResource' {ResourceType
resourceType :: ResourceType
$sel:resourceType:GetAssociatedResource' :: GetAssociatedResource -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: GetAssociatedResource
s@GetAssociatedResource' {} ResourceType
a -> GetAssociatedResource
s {$sel:resourceType:GetAssociatedResource' :: ResourceType
resourceType = ResourceType
a} :: GetAssociatedResource)

-- | The name or ID of the resource associated with the application.
getAssociatedResource_resource :: Lens.Lens' GetAssociatedResource Prelude.Text
getAssociatedResource_resource :: (Text -> f Text)
-> GetAssociatedResource -> f GetAssociatedResource
getAssociatedResource_resource = (GetAssociatedResource -> Text)
-> (GetAssociatedResource -> Text -> GetAssociatedResource)
-> Lens GetAssociatedResource GetAssociatedResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssociatedResource' {Text
resource :: Text
$sel:resource:GetAssociatedResource' :: GetAssociatedResource -> Text
resource} -> Text
resource) (\s :: GetAssociatedResource
s@GetAssociatedResource' {} Text
a -> GetAssociatedResource
s {$sel:resource:GetAssociatedResource' :: Text
resource = Text
a} :: GetAssociatedResource)

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

instance Prelude.NFData GetAssociatedResource

instance Core.ToHeaders GetAssociatedResource where
  toHeaders :: GetAssociatedResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetAssociatedResource -> 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 GetAssociatedResource where
  toPath :: GetAssociatedResource -> ByteString
toPath GetAssociatedResource' {Text
ResourceType
resource :: Text
resourceType :: ResourceType
application :: Text
$sel:resource:GetAssociatedResource' :: GetAssociatedResource -> Text
$sel:resourceType:GetAssociatedResource' :: GetAssociatedResource -> ResourceType
$sel:application:GetAssociatedResource' :: GetAssociatedResource -> 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 GetAssociatedResource where
  toQuery :: GetAssociatedResource -> QueryString
toQuery = QueryString -> GetAssociatedResource -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'GetAssociatedResourceResponse' 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:
--
-- 'resource', 'getAssociatedResourceResponse_resource' - The resource associated with the application.
--
-- 'httpStatus', 'getAssociatedResourceResponse_httpStatus' - The response's http status code.
newGetAssociatedResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAssociatedResourceResponse
newGetAssociatedResourceResponse :: Int -> GetAssociatedResourceResponse
newGetAssociatedResourceResponse Int
pHttpStatus_ =
  GetAssociatedResourceResponse' :: Maybe Resource -> Int -> GetAssociatedResourceResponse
GetAssociatedResourceResponse'
    { $sel:resource:GetAssociatedResourceResponse' :: Maybe Resource
resource =
        Maybe Resource
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAssociatedResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The resource associated with the application.
getAssociatedResourceResponse_resource :: Lens.Lens' GetAssociatedResourceResponse (Prelude.Maybe Resource)
getAssociatedResourceResponse_resource :: (Maybe Resource -> f (Maybe Resource))
-> GetAssociatedResourceResponse -> f GetAssociatedResourceResponse
getAssociatedResourceResponse_resource = (GetAssociatedResourceResponse -> Maybe Resource)
-> (GetAssociatedResourceResponse
    -> Maybe Resource -> GetAssociatedResourceResponse)
-> Lens
     GetAssociatedResourceResponse
     GetAssociatedResourceResponse
     (Maybe Resource)
     (Maybe Resource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAssociatedResourceResponse' {Maybe Resource
resource :: Maybe Resource
$sel:resource:GetAssociatedResourceResponse' :: GetAssociatedResourceResponse -> Maybe Resource
resource} -> Maybe Resource
resource) (\s :: GetAssociatedResourceResponse
s@GetAssociatedResourceResponse' {} Maybe Resource
a -> GetAssociatedResourceResponse
s {$sel:resource:GetAssociatedResourceResponse' :: Maybe Resource
resource = Maybe Resource
a} :: GetAssociatedResourceResponse)

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

instance Prelude.NFData GetAssociatedResourceResponse