{-# 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-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)
--
-- 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.Lens as Lens
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
(AssociateCertificate -> AssociateCertificate -> Bool)
-> (AssociateCertificate -> AssociateCertificate -> Bool)
-> Eq AssociateCertificate
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]
(Int -> ReadS AssociateCertificate)
-> ReadS [AssociateCertificate]
-> ReadPrec AssociateCertificate
-> ReadPrec [AssociateCertificate]
-> Read 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
(Int -> AssociateCertificate -> ShowS)
-> (AssociateCertificate -> String)
-> ([AssociateCertificate] -> ShowS)
-> Show AssociateCertificate
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. AssociateCertificate -> Rep AssociateCertificate x)
-> (forall x. Rep AssociateCertificate x -> AssociateCertificate)
-> Generic AssociateCertificate
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' :: Text -> AssociateCertificate
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 :: (Text -> f Text) -> AssociateCertificate -> f AssociateCertificate
associateCertificate_arn = (AssociateCertificate -> Text)
-> (AssociateCertificate -> Text -> AssociateCertificate)
-> Lens AssociateCertificate AssociateCertificate Text Text
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 :: AssociateCertificate -> Request AssociateCertificate
request = Service -> AssociateCertificate -> Request AssociateCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateCertificate))
-> Logger
-> Service
-> Proxy AssociateCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateCertificateResponse
AssociateCertificateResponse'
            (Int -> AssociateCertificateResponse)
-> Either String Int -> Either String AssociateCertificateResponse
forall (f :: * -> *) a b. Functor 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 AssociateCertificate

instance Prelude.NFData AssociateCertificate

instance Core.ToHeaders AssociateCertificate where
  toHeaders :: AssociateCertificate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateCertificate -> 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 AssociateCertificate where
  toJSON :: AssociateCertificate -> Value
toJSON AssociateCertificate' {Text
arn :: Text
$sel:arn:AssociateCertificate' :: AssociateCertificate -> 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
"arn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
arn)]
      )

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

instance Core.ToQuery AssociateCertificate where
  toQuery :: AssociateCertificate -> QueryString
toQuery = QueryString -> AssociateCertificate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(AssociateCertificateResponse
 -> AssociateCertificateResponse -> Bool)
-> (AssociateCertificateResponse
    -> AssociateCertificateResponse -> Bool)
-> Eq AssociateCertificateResponse
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]
(Int -> ReadS AssociateCertificateResponse)
-> ReadS [AssociateCertificateResponse]
-> ReadPrec AssociateCertificateResponse
-> ReadPrec [AssociateCertificateResponse]
-> Read 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
(Int -> AssociateCertificateResponse -> ShowS)
-> (AssociateCertificateResponse -> String)
-> ([AssociateCertificateResponse] -> ShowS)
-> Show AssociateCertificateResponse
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.
 AssociateCertificateResponse -> Rep AssociateCertificateResponse x)
-> (forall x.
    Rep AssociateCertificateResponse x -> AssociateCertificateResponse)
-> Generic AssociateCertificateResponse
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' :: Int -> AssociateCertificateResponse
AssociateCertificateResponse'
    { $sel:httpStatus:AssociateCertificateResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
associateCertificateResponse_httpStatus :: Lens.Lens' AssociateCertificateResponse Prelude.Int
associateCertificateResponse_httpStatus :: (Int -> f Int)
-> AssociateCertificateResponse -> f AssociateCertificateResponse
associateCertificateResponse_httpStatus = (AssociateCertificateResponse -> Int)
-> (AssociateCertificateResponse
    -> Int -> AssociateCertificateResponse)
-> Lens
     AssociateCertificateResponse AssociateCertificateResponse Int Int
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