{-# 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.MediaConvert.AssociateCertificate
-- 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 AWS Certificate Manager (ACM) Amazon Resource Name (ARN)
-- with AWS Elemental MediaConvert.
module Amazonka.MediaConvert.AssociateCertificate
  ( -- * Creating a Request
    AssociateCertificate (..),
    newAssociateCertificate,

    -- * Request Lenses
    associateCertificate_arn,

    -- * Destructuring the Response
    AssociateCertificateResponse (..),
    newAssociateCertificateResponse,

    -- * Response Lenses
    associateCertificateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateCertificate' smart constructor.
data AssociateCertificate = AssociateCertificate'
  { -- | The ARN of the ACM certificate that you want to associate with your
    -- MediaConvert resource.
    AssociateCertificate -> Text
arn :: Prelude.Text
  }
  deriving (AssociateCertificate -> AssociateCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateCertificate -> AssociateCertificate -> Bool
$c/= :: AssociateCertificate -> AssociateCertificate -> Bool
== :: AssociateCertificate -> AssociateCertificate -> Bool
$c== :: AssociateCertificate -> AssociateCertificate -> Bool
Prelude.Eq, ReadPrec [AssociateCertificate]
ReadPrec AssociateCertificate
Int -> ReadS AssociateCertificate
ReadS [AssociateCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateCertificate]
$creadListPrec :: ReadPrec [AssociateCertificate]
readPrec :: ReadPrec AssociateCertificate
$creadPrec :: ReadPrec AssociateCertificate
readList :: ReadS [AssociateCertificate]
$creadList :: ReadS [AssociateCertificate]
readsPrec :: Int -> ReadS AssociateCertificate
$creadsPrec :: Int -> ReadS AssociateCertificate
Prelude.Read, Int -> AssociateCertificate -> ShowS
[AssociateCertificate] -> ShowS
AssociateCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateCertificate] -> ShowS
$cshowList :: [AssociateCertificate] -> ShowS
show :: AssociateCertificate -> String
$cshow :: AssociateCertificate -> String
showsPrec :: Int -> AssociateCertificate -> ShowS
$cshowsPrec :: Int -> AssociateCertificate -> ShowS
Prelude.Show, forall x. Rep AssociateCertificate x -> AssociateCertificate
forall x. AssociateCertificate -> Rep AssociateCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateCertificate x -> AssociateCertificate
$cfrom :: forall x. AssociateCertificate -> Rep AssociateCertificate x
Prelude.Generic)

-- |
-- Create a value of 'AssociateCertificate' 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:
--
-- 'arn', 'associateCertificate_arn' - The ARN of the ACM certificate that you want to associate with your
-- MediaConvert resource.
newAssociateCertificate ::
  -- | 'arn'
  Prelude.Text ->
  AssociateCertificate
newAssociateCertificate :: Text -> AssociateCertificate
newAssociateCertificate Text
pArn_ =
  AssociateCertificate' {$sel:arn:AssociateCertificate' :: Text
arn = Text
pArn_}

-- | The ARN of the ACM certificate that you want to associate with your
-- MediaConvert resource.
associateCertificate_arn :: Lens.Lens' AssociateCertificate Prelude.Text
associateCertificate_arn :: Lens' AssociateCertificate Text
associateCertificate_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateCertificate' {Text
arn :: Text
$sel:arn:AssociateCertificate' :: AssociateCertificate -> Text
arn} -> Text
arn) (\s :: AssociateCertificate
s@AssociateCertificate' {} Text
a -> AssociateCertificate
s {$sel:arn:AssociateCertificate' :: Text
arn = Text
a} :: AssociateCertificate)

instance Core.AWSRequest AssociateCertificate where
  type
    AWSResponse AssociateCertificate =
      AssociateCertificateResponse
  request :: (Service -> Service)
-> AssociateCertificate -> Request AssociateCertificate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateCertificateResponse
AssociateCertificateResponse'
            forall (f :: * -> *) a b. Functor 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 AssociateCertificate where
  hashWithSalt :: Int -> AssociateCertificate -> Int
hashWithSalt Int
_salt AssociateCertificate' {Text
arn :: Text
$sel:arn:AssociateCertificate' :: AssociateCertificate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData AssociateCertificate where
  rnf :: AssociateCertificate -> ()
rnf AssociateCertificate' {Text
arn :: Text
$sel:arn:AssociateCertificate' :: AssociateCertificate -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
arn

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

instance Data.ToPath AssociateCertificate where
  toPath :: AssociateCertificate -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2017-08-29/certificates"

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

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

-- |
-- Create a value of 'AssociateCertificateResponse' 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:
--
-- 'httpStatus', 'associateCertificateResponse_httpStatus' - The response's http status code.
newAssociateCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateCertificateResponse
newAssociateCertificateResponse :: Int -> AssociateCertificateResponse
newAssociateCertificateResponse Int
pHttpStatus_ =
  AssociateCertificateResponse'
    { $sel:httpStatus:AssociateCertificateResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData AssociateCertificateResponse where
  rnf :: AssociateCertificateResponse -> ()
rnf AssociateCertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateCertificateResponse' :: AssociateCertificateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus