{-# 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.AssociateAttributeGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates an attribute group with an application to augment the
-- application\'s metadata with the group\'s attributes. This feature
-- enables applications to be described with user-defined details that are
-- machine-readable, such as third-party integrations.
module Amazonka.ServiceCatalogAppRegistry.AssociateAttributeGroup
  ( -- * Creating a Request
    AssociateAttributeGroup (..),
    newAssociateAttributeGroup,

    -- * Request Lenses
    associateAttributeGroup_application,
    associateAttributeGroup_attributeGroup,

    -- * Destructuring the Response
    AssociateAttributeGroupResponse (..),
    newAssociateAttributeGroupResponse,

    -- * Response Lenses
    associateAttributeGroupResponse_applicationArn,
    associateAttributeGroupResponse_attributeGroupArn,
    associateAttributeGroupResponse_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:/ 'newAssociateAttributeGroup' smart constructor.
data AssociateAttributeGroup = AssociateAttributeGroup'
  { -- | The name or ID of the application.
    AssociateAttributeGroup -> Text
application :: Prelude.Text,
    -- | The name or ID of the attribute group that holds the attributes to
    -- describe the application.
    AssociateAttributeGroup -> Text
attributeGroup :: Prelude.Text
  }
  deriving (AssociateAttributeGroup -> AssociateAttributeGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAttributeGroup -> AssociateAttributeGroup -> Bool
$c/= :: AssociateAttributeGroup -> AssociateAttributeGroup -> Bool
== :: AssociateAttributeGroup -> AssociateAttributeGroup -> Bool
$c== :: AssociateAttributeGroup -> AssociateAttributeGroup -> Bool
Prelude.Eq, ReadPrec [AssociateAttributeGroup]
ReadPrec AssociateAttributeGroup
Int -> ReadS AssociateAttributeGroup
ReadS [AssociateAttributeGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAttributeGroup]
$creadListPrec :: ReadPrec [AssociateAttributeGroup]
readPrec :: ReadPrec AssociateAttributeGroup
$creadPrec :: ReadPrec AssociateAttributeGroup
readList :: ReadS [AssociateAttributeGroup]
$creadList :: ReadS [AssociateAttributeGroup]
readsPrec :: Int -> ReadS AssociateAttributeGroup
$creadsPrec :: Int -> ReadS AssociateAttributeGroup
Prelude.Read, Int -> AssociateAttributeGroup -> ShowS
[AssociateAttributeGroup] -> ShowS
AssociateAttributeGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAttributeGroup] -> ShowS
$cshowList :: [AssociateAttributeGroup] -> ShowS
show :: AssociateAttributeGroup -> String
$cshow :: AssociateAttributeGroup -> String
showsPrec :: Int -> AssociateAttributeGroup -> ShowS
$cshowsPrec :: Int -> AssociateAttributeGroup -> ShowS
Prelude.Show, forall x. Rep AssociateAttributeGroup x -> AssociateAttributeGroup
forall x. AssociateAttributeGroup -> Rep AssociateAttributeGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateAttributeGroup x -> AssociateAttributeGroup
$cfrom :: forall x. AssociateAttributeGroup -> Rep AssociateAttributeGroup x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAttributeGroup' 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', 'associateAttributeGroup_application' - The name or ID of the application.
--
-- 'attributeGroup', 'associateAttributeGroup_attributeGroup' - The name or ID of the attribute group that holds the attributes to
-- describe the application.
newAssociateAttributeGroup ::
  -- | 'application'
  Prelude.Text ->
  -- | 'attributeGroup'
  Prelude.Text ->
  AssociateAttributeGroup
newAssociateAttributeGroup :: Text -> Text -> AssociateAttributeGroup
newAssociateAttributeGroup
  Text
pApplication_
  Text
pAttributeGroup_ =
    AssociateAttributeGroup'
      { $sel:application:AssociateAttributeGroup' :: Text
application =
          Text
pApplication_,
        $sel:attributeGroup:AssociateAttributeGroup' :: Text
attributeGroup = Text
pAttributeGroup_
      }

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

-- | The name or ID of the attribute group that holds the attributes to
-- describe the application.
associateAttributeGroup_attributeGroup :: Lens.Lens' AssociateAttributeGroup Prelude.Text
associateAttributeGroup_attributeGroup :: Lens' AssociateAttributeGroup Text
associateAttributeGroup_attributeGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAttributeGroup' {Text
attributeGroup :: Text
$sel:attributeGroup:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
attributeGroup} -> Text
attributeGroup) (\s :: AssociateAttributeGroup
s@AssociateAttributeGroup' {} Text
a -> AssociateAttributeGroup
s {$sel:attributeGroup:AssociateAttributeGroup' :: Text
attributeGroup = Text
a} :: AssociateAttributeGroup)

instance Core.AWSRequest AssociateAttributeGroup where
  type
    AWSResponse AssociateAttributeGroup =
      AssociateAttributeGroupResponse
  request :: (Service -> Service)
-> AssociateAttributeGroup -> Request AssociateAttributeGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateAttributeGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateAttributeGroup)))
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 -> AssociateAttributeGroupResponse
AssociateAttributeGroupResponse'
            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
"attributeGroupArn")
            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 AssociateAttributeGroup where
  hashWithSalt :: Int -> AssociateAttributeGroup -> Int
hashWithSalt Int
_salt AssociateAttributeGroup' {Text
attributeGroup :: Text
application :: Text
$sel:attributeGroup:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
$sel:application:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
application
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
attributeGroup

instance Prelude.NFData AssociateAttributeGroup where
  rnf :: AssociateAttributeGroup -> ()
rnf AssociateAttributeGroup' {Text
attributeGroup :: Text
application :: Text
$sel:attributeGroup:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
$sel:application:AssociateAttributeGroup' :: AssociateAttributeGroup -> 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 Text
attributeGroup

instance Data.ToHeaders AssociateAttributeGroup where
  toHeaders :: AssociateAttributeGroup -> 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 AssociateAttributeGroup where
  toJSON :: AssociateAttributeGroup -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath AssociateAttributeGroup where
  toPath :: AssociateAttributeGroup -> ByteString
toPath AssociateAttributeGroup' {Text
attributeGroup :: Text
application :: Text
$sel:attributeGroup:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
$sel:application:AssociateAttributeGroup' :: AssociateAttributeGroup -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
application,
        ByteString
"/attribute-groups/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
attributeGroup
      ]

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

-- | /See:/ 'newAssociateAttributeGroupResponse' smart constructor.
data AssociateAttributeGroupResponse = AssociateAttributeGroupResponse'
  { -- | The Amazon resource name (ARN) of the application that was augmented
    -- with attributes.
    AssociateAttributeGroupResponse -> Maybe Text
applicationArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon resource name (ARN) of the attribute group that contains the
    -- application\'s new attributes.
    AssociateAttributeGroupResponse -> Maybe Text
attributeGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AssociateAttributeGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateAttributeGroupResponse
-> AssociateAttributeGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateAttributeGroupResponse
-> AssociateAttributeGroupResponse -> Bool
$c/= :: AssociateAttributeGroupResponse
-> AssociateAttributeGroupResponse -> Bool
== :: AssociateAttributeGroupResponse
-> AssociateAttributeGroupResponse -> Bool
$c== :: AssociateAttributeGroupResponse
-> AssociateAttributeGroupResponse -> Bool
Prelude.Eq, ReadPrec [AssociateAttributeGroupResponse]
ReadPrec AssociateAttributeGroupResponse
Int -> ReadS AssociateAttributeGroupResponse
ReadS [AssociateAttributeGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateAttributeGroupResponse]
$creadListPrec :: ReadPrec [AssociateAttributeGroupResponse]
readPrec :: ReadPrec AssociateAttributeGroupResponse
$creadPrec :: ReadPrec AssociateAttributeGroupResponse
readList :: ReadS [AssociateAttributeGroupResponse]
$creadList :: ReadS [AssociateAttributeGroupResponse]
readsPrec :: Int -> ReadS AssociateAttributeGroupResponse
$creadsPrec :: Int -> ReadS AssociateAttributeGroupResponse
Prelude.Read, Int -> AssociateAttributeGroupResponse -> ShowS
[AssociateAttributeGroupResponse] -> ShowS
AssociateAttributeGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateAttributeGroupResponse] -> ShowS
$cshowList :: [AssociateAttributeGroupResponse] -> ShowS
show :: AssociateAttributeGroupResponse -> String
$cshow :: AssociateAttributeGroupResponse -> String
showsPrec :: Int -> AssociateAttributeGroupResponse -> ShowS
$cshowsPrec :: Int -> AssociateAttributeGroupResponse -> ShowS
Prelude.Show, forall x.
Rep AssociateAttributeGroupResponse x
-> AssociateAttributeGroupResponse
forall x.
AssociateAttributeGroupResponse
-> Rep AssociateAttributeGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateAttributeGroupResponse x
-> AssociateAttributeGroupResponse
$cfrom :: forall x.
AssociateAttributeGroupResponse
-> Rep AssociateAttributeGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateAttributeGroupResponse' 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', 'associateAttributeGroupResponse_applicationArn' - The Amazon resource name (ARN) of the application that was augmented
-- with attributes.
--
-- 'attributeGroupArn', 'associateAttributeGroupResponse_attributeGroupArn' - The Amazon resource name (ARN) of the attribute group that contains the
-- application\'s new attributes.
--
-- 'httpStatus', 'associateAttributeGroupResponse_httpStatus' - The response's http status code.
newAssociateAttributeGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateAttributeGroupResponse
newAssociateAttributeGroupResponse :: Int -> AssociateAttributeGroupResponse
newAssociateAttributeGroupResponse Int
pHttpStatus_ =
  AssociateAttributeGroupResponse'
    { $sel:applicationArn:AssociateAttributeGroupResponse' :: Maybe Text
applicationArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attributeGroupArn:AssociateAttributeGroupResponse' :: Maybe Text
attributeGroupArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AssociateAttributeGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon resource name (ARN) of the application that was augmented
-- with attributes.
associateAttributeGroupResponse_applicationArn :: Lens.Lens' AssociateAttributeGroupResponse (Prelude.Maybe Prelude.Text)
associateAttributeGroupResponse_applicationArn :: Lens' AssociateAttributeGroupResponse (Maybe Text)
associateAttributeGroupResponse_applicationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAttributeGroupResponse' {Maybe Text
applicationArn :: Maybe Text
$sel:applicationArn:AssociateAttributeGroupResponse' :: AssociateAttributeGroupResponse -> Maybe Text
applicationArn} -> Maybe Text
applicationArn) (\s :: AssociateAttributeGroupResponse
s@AssociateAttributeGroupResponse' {} Maybe Text
a -> AssociateAttributeGroupResponse
s {$sel:applicationArn:AssociateAttributeGroupResponse' :: Maybe Text
applicationArn = Maybe Text
a} :: AssociateAttributeGroupResponse)

-- | The Amazon resource name (ARN) of the attribute group that contains the
-- application\'s new attributes.
associateAttributeGroupResponse_attributeGroupArn :: Lens.Lens' AssociateAttributeGroupResponse (Prelude.Maybe Prelude.Text)
associateAttributeGroupResponse_attributeGroupArn :: Lens' AssociateAttributeGroupResponse (Maybe Text)
associateAttributeGroupResponse_attributeGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateAttributeGroupResponse' {Maybe Text
attributeGroupArn :: Maybe Text
$sel:attributeGroupArn:AssociateAttributeGroupResponse' :: AssociateAttributeGroupResponse -> Maybe Text
attributeGroupArn} -> Maybe Text
attributeGroupArn) (\s :: AssociateAttributeGroupResponse
s@AssociateAttributeGroupResponse' {} Maybe Text
a -> AssociateAttributeGroupResponse
s {$sel:attributeGroupArn:AssociateAttributeGroupResponse' :: Maybe Text
attributeGroupArn = Maybe Text
a} :: AssociateAttributeGroupResponse)

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

instance
  Prelude.NFData
    AssociateAttributeGroupResponse
  where
  rnf :: AssociateAttributeGroupResponse -> ()
rnf AssociateAttributeGroupResponse' {Int
Maybe Text
httpStatus :: Int
attributeGroupArn :: Maybe Text
applicationArn :: Maybe Text
$sel:httpStatus:AssociateAttributeGroupResponse' :: AssociateAttributeGroupResponse -> Int
$sel:attributeGroupArn:AssociateAttributeGroupResponse' :: AssociateAttributeGroupResponse -> Maybe Text
$sel:applicationArn:AssociateAttributeGroupResponse' :: AssociateAttributeGroupResponse -> 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
attributeGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus