{-# 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.SecurityHub.EnableImportFindingsForProduct
-- 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)
--
-- Enables the integration of a partner product with Security Hub.
-- Integrated products send findings to Security Hub.
--
-- When you enable a product integration, a permissions policy that grants
-- permission for the product to send findings to Security Hub is applied.
module Amazonka.SecurityHub.EnableImportFindingsForProduct
  ( -- * Creating a Request
    EnableImportFindingsForProduct (..),
    newEnableImportFindingsForProduct,

    -- * Request Lenses
    enableImportFindingsForProduct_productArn,

    -- * Destructuring the Response
    EnableImportFindingsForProductResponse (..),
    newEnableImportFindingsForProductResponse,

    -- * Response Lenses
    enableImportFindingsForProductResponse_productSubscriptionArn,
    enableImportFindingsForProductResponse_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.SecurityHub.Types

-- | /See:/ 'newEnableImportFindingsForProduct' smart constructor.
data EnableImportFindingsForProduct = EnableImportFindingsForProduct'
  { -- | The ARN of the product to enable the integration for.
    EnableImportFindingsForProduct -> Text
productArn :: Prelude.Text
  }
  deriving (EnableImportFindingsForProduct
-> EnableImportFindingsForProduct -> Bool
(EnableImportFindingsForProduct
 -> EnableImportFindingsForProduct -> Bool)
-> (EnableImportFindingsForProduct
    -> EnableImportFindingsForProduct -> Bool)
-> Eq EnableImportFindingsForProduct
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableImportFindingsForProduct
-> EnableImportFindingsForProduct -> Bool
$c/= :: EnableImportFindingsForProduct
-> EnableImportFindingsForProduct -> Bool
== :: EnableImportFindingsForProduct
-> EnableImportFindingsForProduct -> Bool
$c== :: EnableImportFindingsForProduct
-> EnableImportFindingsForProduct -> Bool
Prelude.Eq, ReadPrec [EnableImportFindingsForProduct]
ReadPrec EnableImportFindingsForProduct
Int -> ReadS EnableImportFindingsForProduct
ReadS [EnableImportFindingsForProduct]
(Int -> ReadS EnableImportFindingsForProduct)
-> ReadS [EnableImportFindingsForProduct]
-> ReadPrec EnableImportFindingsForProduct
-> ReadPrec [EnableImportFindingsForProduct]
-> Read EnableImportFindingsForProduct
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableImportFindingsForProduct]
$creadListPrec :: ReadPrec [EnableImportFindingsForProduct]
readPrec :: ReadPrec EnableImportFindingsForProduct
$creadPrec :: ReadPrec EnableImportFindingsForProduct
readList :: ReadS [EnableImportFindingsForProduct]
$creadList :: ReadS [EnableImportFindingsForProduct]
readsPrec :: Int -> ReadS EnableImportFindingsForProduct
$creadsPrec :: Int -> ReadS EnableImportFindingsForProduct
Prelude.Read, Int -> EnableImportFindingsForProduct -> ShowS
[EnableImportFindingsForProduct] -> ShowS
EnableImportFindingsForProduct -> String
(Int -> EnableImportFindingsForProduct -> ShowS)
-> (EnableImportFindingsForProduct -> String)
-> ([EnableImportFindingsForProduct] -> ShowS)
-> Show EnableImportFindingsForProduct
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableImportFindingsForProduct] -> ShowS
$cshowList :: [EnableImportFindingsForProduct] -> ShowS
show :: EnableImportFindingsForProduct -> String
$cshow :: EnableImportFindingsForProduct -> String
showsPrec :: Int -> EnableImportFindingsForProduct -> ShowS
$cshowsPrec :: Int -> EnableImportFindingsForProduct -> ShowS
Prelude.Show, (forall x.
 EnableImportFindingsForProduct
 -> Rep EnableImportFindingsForProduct x)
-> (forall x.
    Rep EnableImportFindingsForProduct x
    -> EnableImportFindingsForProduct)
-> Generic EnableImportFindingsForProduct
forall x.
Rep EnableImportFindingsForProduct x
-> EnableImportFindingsForProduct
forall x.
EnableImportFindingsForProduct
-> Rep EnableImportFindingsForProduct x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableImportFindingsForProduct x
-> EnableImportFindingsForProduct
$cfrom :: forall x.
EnableImportFindingsForProduct
-> Rep EnableImportFindingsForProduct x
Prelude.Generic)

-- |
-- Create a value of 'EnableImportFindingsForProduct' 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:
--
-- 'productArn', 'enableImportFindingsForProduct_productArn' - The ARN of the product to enable the integration for.
newEnableImportFindingsForProduct ::
  -- | 'productArn'
  Prelude.Text ->
  EnableImportFindingsForProduct
newEnableImportFindingsForProduct :: Text -> EnableImportFindingsForProduct
newEnableImportFindingsForProduct Text
pProductArn_ =
  EnableImportFindingsForProduct' :: Text -> EnableImportFindingsForProduct
EnableImportFindingsForProduct'
    { $sel:productArn:EnableImportFindingsForProduct' :: Text
productArn =
        Text
pProductArn_
    }

-- | The ARN of the product to enable the integration for.
enableImportFindingsForProduct_productArn :: Lens.Lens' EnableImportFindingsForProduct Prelude.Text
enableImportFindingsForProduct_productArn :: (Text -> f Text)
-> EnableImportFindingsForProduct
-> f EnableImportFindingsForProduct
enableImportFindingsForProduct_productArn = (EnableImportFindingsForProduct -> Text)
-> (EnableImportFindingsForProduct
    -> Text -> EnableImportFindingsForProduct)
-> Lens
     EnableImportFindingsForProduct
     EnableImportFindingsForProduct
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableImportFindingsForProduct' {Text
productArn :: Text
$sel:productArn:EnableImportFindingsForProduct' :: EnableImportFindingsForProduct -> Text
productArn} -> Text
productArn) (\s :: EnableImportFindingsForProduct
s@EnableImportFindingsForProduct' {} Text
a -> EnableImportFindingsForProduct
s {$sel:productArn:EnableImportFindingsForProduct' :: Text
productArn = Text
a} :: EnableImportFindingsForProduct)

instance
  Core.AWSRequest
    EnableImportFindingsForProduct
  where
  type
    AWSResponse EnableImportFindingsForProduct =
      EnableImportFindingsForProductResponse
  request :: EnableImportFindingsForProduct
-> Request EnableImportFindingsForProduct
request = Service
-> EnableImportFindingsForProduct
-> Request EnableImportFindingsForProduct
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableImportFindingsForProduct
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse EnableImportFindingsForProduct)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse EnableImportFindingsForProduct))
-> Logger
-> Service
-> Proxy EnableImportFindingsForProduct
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse EnableImportFindingsForProduct)))
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 -> Int -> EnableImportFindingsForProductResponse
EnableImportFindingsForProductResponse'
            (Maybe Text -> Int -> EnableImportFindingsForProductResponse)
-> Either String (Maybe Text)
-> Either String (Int -> EnableImportFindingsForProductResponse)
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
"ProductSubscriptionArn")
            Either String (Int -> EnableImportFindingsForProductResponse)
-> Either String Int
-> Either String EnableImportFindingsForProductResponse
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
    EnableImportFindingsForProduct

instance
  Prelude.NFData
    EnableImportFindingsForProduct

instance
  Core.ToHeaders
    EnableImportFindingsForProduct
  where
  toHeaders :: EnableImportFindingsForProduct -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> EnableImportFindingsForProduct -> 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.ToJSON EnableImportFindingsForProduct where
  toJSON :: EnableImportFindingsForProduct -> Value
toJSON EnableImportFindingsForProduct' {Text
productArn :: Text
$sel:productArn:EnableImportFindingsForProduct' :: EnableImportFindingsForProduct -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productArn)]
      )

instance Core.ToPath EnableImportFindingsForProduct where
  toPath :: EnableImportFindingsForProduct -> ByteString
toPath = ByteString -> EnableImportFindingsForProduct -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/productSubscriptions"

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

-- | /See:/ 'newEnableImportFindingsForProductResponse' smart constructor.
data EnableImportFindingsForProductResponse = EnableImportFindingsForProductResponse'
  { -- | The ARN of your subscription to the product to enable integrations for.
    EnableImportFindingsForProductResponse -> Maybe Text
productSubscriptionArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    EnableImportFindingsForProductResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (EnableImportFindingsForProductResponse
-> EnableImportFindingsForProductResponse -> Bool
(EnableImportFindingsForProductResponse
 -> EnableImportFindingsForProductResponse -> Bool)
-> (EnableImportFindingsForProductResponse
    -> EnableImportFindingsForProductResponse -> Bool)
-> Eq EnableImportFindingsForProductResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableImportFindingsForProductResponse
-> EnableImportFindingsForProductResponse -> Bool
$c/= :: EnableImportFindingsForProductResponse
-> EnableImportFindingsForProductResponse -> Bool
== :: EnableImportFindingsForProductResponse
-> EnableImportFindingsForProductResponse -> Bool
$c== :: EnableImportFindingsForProductResponse
-> EnableImportFindingsForProductResponse -> Bool
Prelude.Eq, ReadPrec [EnableImportFindingsForProductResponse]
ReadPrec EnableImportFindingsForProductResponse
Int -> ReadS EnableImportFindingsForProductResponse
ReadS [EnableImportFindingsForProductResponse]
(Int -> ReadS EnableImportFindingsForProductResponse)
-> ReadS [EnableImportFindingsForProductResponse]
-> ReadPrec EnableImportFindingsForProductResponse
-> ReadPrec [EnableImportFindingsForProductResponse]
-> Read EnableImportFindingsForProductResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableImportFindingsForProductResponse]
$creadListPrec :: ReadPrec [EnableImportFindingsForProductResponse]
readPrec :: ReadPrec EnableImportFindingsForProductResponse
$creadPrec :: ReadPrec EnableImportFindingsForProductResponse
readList :: ReadS [EnableImportFindingsForProductResponse]
$creadList :: ReadS [EnableImportFindingsForProductResponse]
readsPrec :: Int -> ReadS EnableImportFindingsForProductResponse
$creadsPrec :: Int -> ReadS EnableImportFindingsForProductResponse
Prelude.Read, Int -> EnableImportFindingsForProductResponse -> ShowS
[EnableImportFindingsForProductResponse] -> ShowS
EnableImportFindingsForProductResponse -> String
(Int -> EnableImportFindingsForProductResponse -> ShowS)
-> (EnableImportFindingsForProductResponse -> String)
-> ([EnableImportFindingsForProductResponse] -> ShowS)
-> Show EnableImportFindingsForProductResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableImportFindingsForProductResponse] -> ShowS
$cshowList :: [EnableImportFindingsForProductResponse] -> ShowS
show :: EnableImportFindingsForProductResponse -> String
$cshow :: EnableImportFindingsForProductResponse -> String
showsPrec :: Int -> EnableImportFindingsForProductResponse -> ShowS
$cshowsPrec :: Int -> EnableImportFindingsForProductResponse -> ShowS
Prelude.Show, (forall x.
 EnableImportFindingsForProductResponse
 -> Rep EnableImportFindingsForProductResponse x)
-> (forall x.
    Rep EnableImportFindingsForProductResponse x
    -> EnableImportFindingsForProductResponse)
-> Generic EnableImportFindingsForProductResponse
forall x.
Rep EnableImportFindingsForProductResponse x
-> EnableImportFindingsForProductResponse
forall x.
EnableImportFindingsForProductResponse
-> Rep EnableImportFindingsForProductResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableImportFindingsForProductResponse x
-> EnableImportFindingsForProductResponse
$cfrom :: forall x.
EnableImportFindingsForProductResponse
-> Rep EnableImportFindingsForProductResponse x
Prelude.Generic)

-- |
-- Create a value of 'EnableImportFindingsForProductResponse' 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:
--
-- 'productSubscriptionArn', 'enableImportFindingsForProductResponse_productSubscriptionArn' - The ARN of your subscription to the product to enable integrations for.
--
-- 'httpStatus', 'enableImportFindingsForProductResponse_httpStatus' - The response's http status code.
newEnableImportFindingsForProductResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  EnableImportFindingsForProductResponse
newEnableImportFindingsForProductResponse :: Int -> EnableImportFindingsForProductResponse
newEnableImportFindingsForProductResponse
  Int
pHttpStatus_ =
    EnableImportFindingsForProductResponse' :: Maybe Text -> Int -> EnableImportFindingsForProductResponse
EnableImportFindingsForProductResponse'
      { $sel:productSubscriptionArn:EnableImportFindingsForProductResponse' :: Maybe Text
productSubscriptionArn =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:EnableImportFindingsForProductResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The ARN of your subscription to the product to enable integrations for.
enableImportFindingsForProductResponse_productSubscriptionArn :: Lens.Lens' EnableImportFindingsForProductResponse (Prelude.Maybe Prelude.Text)
enableImportFindingsForProductResponse_productSubscriptionArn :: (Maybe Text -> f (Maybe Text))
-> EnableImportFindingsForProductResponse
-> f EnableImportFindingsForProductResponse
enableImportFindingsForProductResponse_productSubscriptionArn = (EnableImportFindingsForProductResponse -> Maybe Text)
-> (EnableImportFindingsForProductResponse
    -> Maybe Text -> EnableImportFindingsForProductResponse)
-> Lens
     EnableImportFindingsForProductResponse
     EnableImportFindingsForProductResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableImportFindingsForProductResponse' {Maybe Text
productSubscriptionArn :: Maybe Text
$sel:productSubscriptionArn:EnableImportFindingsForProductResponse' :: EnableImportFindingsForProductResponse -> Maybe Text
productSubscriptionArn} -> Maybe Text
productSubscriptionArn) (\s :: EnableImportFindingsForProductResponse
s@EnableImportFindingsForProductResponse' {} Maybe Text
a -> EnableImportFindingsForProductResponse
s {$sel:productSubscriptionArn:EnableImportFindingsForProductResponse' :: Maybe Text
productSubscriptionArn = Maybe Text
a} :: EnableImportFindingsForProductResponse)

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

instance
  Prelude.NFData
    EnableImportFindingsForProductResponse