{-# 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.CloudFormation.RegisterPublisher
-- 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)
--
-- Registers your account as a publisher of public extensions in the
-- CloudFormation registry. Public extensions are available for use by all
-- CloudFormation users. This publisher ID applies to your account in all
-- Amazon Web Services Regions.
--
-- For information on requirements for registering as a public extension
-- publisher, see
-- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/publish-extension.html#publish-extension-prereqs Registering your account to publish CloudFormation extensions>
-- in the /CloudFormation CLI User Guide/.
module Amazonka.CloudFormation.RegisterPublisher
  ( -- * Creating a Request
    RegisterPublisher (..),
    newRegisterPublisher,

    -- * Request Lenses
    registerPublisher_connectionArn,
    registerPublisher_acceptTermsAndConditions,

    -- * Destructuring the Response
    RegisterPublisherResponse (..),
    newRegisterPublisherResponse,

    -- * Response Lenses
    registerPublisherResponse_publisherId,
    registerPublisherResponse_httpStatus,
  )
where

import Amazonka.CloudFormation.Types
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

-- | /See:/ 'newRegisterPublisher' smart constructor.
data RegisterPublisher = RegisterPublisher'
  { -- | If you are using a Bitbucket or GitHub account for identity
    -- verification, the Amazon Resource Name (ARN) for your connection to that
    -- account.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/publish-extension.html#publish-extension-prereqs Registering your account to publish CloudFormation extensions>
    -- in the /CloudFormation CLI User Guide/.
    RegisterPublisher -> Maybe Text
connectionArn :: Prelude.Maybe Prelude.Text,
    -- | Whether you accept the
    -- <https://cloudformation-registry-documents.s3.amazonaws.com/Terms_and_Conditions_for_AWS_CloudFormation_Registry_Publishers.pdf Terms and Conditions>
    -- for publishing extensions in the CloudFormation registry. You must
    -- accept the terms and conditions in order to register to publish public
    -- extensions to the CloudFormation registry.
    --
    -- The default is @false@.
    RegisterPublisher -> Maybe Bool
acceptTermsAndConditions :: Prelude.Maybe Prelude.Bool
  }
  deriving (RegisterPublisher -> RegisterPublisher -> Bool
(RegisterPublisher -> RegisterPublisher -> Bool)
-> (RegisterPublisher -> RegisterPublisher -> Bool)
-> Eq RegisterPublisher
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterPublisher -> RegisterPublisher -> Bool
$c/= :: RegisterPublisher -> RegisterPublisher -> Bool
== :: RegisterPublisher -> RegisterPublisher -> Bool
$c== :: RegisterPublisher -> RegisterPublisher -> Bool
Prelude.Eq, ReadPrec [RegisterPublisher]
ReadPrec RegisterPublisher
Int -> ReadS RegisterPublisher
ReadS [RegisterPublisher]
(Int -> ReadS RegisterPublisher)
-> ReadS [RegisterPublisher]
-> ReadPrec RegisterPublisher
-> ReadPrec [RegisterPublisher]
-> Read RegisterPublisher
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterPublisher]
$creadListPrec :: ReadPrec [RegisterPublisher]
readPrec :: ReadPrec RegisterPublisher
$creadPrec :: ReadPrec RegisterPublisher
readList :: ReadS [RegisterPublisher]
$creadList :: ReadS [RegisterPublisher]
readsPrec :: Int -> ReadS RegisterPublisher
$creadsPrec :: Int -> ReadS RegisterPublisher
Prelude.Read, Int -> RegisterPublisher -> ShowS
[RegisterPublisher] -> ShowS
RegisterPublisher -> String
(Int -> RegisterPublisher -> ShowS)
-> (RegisterPublisher -> String)
-> ([RegisterPublisher] -> ShowS)
-> Show RegisterPublisher
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterPublisher] -> ShowS
$cshowList :: [RegisterPublisher] -> ShowS
show :: RegisterPublisher -> String
$cshow :: RegisterPublisher -> String
showsPrec :: Int -> RegisterPublisher -> ShowS
$cshowsPrec :: Int -> RegisterPublisher -> ShowS
Prelude.Show, (forall x. RegisterPublisher -> Rep RegisterPublisher x)
-> (forall x. Rep RegisterPublisher x -> RegisterPublisher)
-> Generic RegisterPublisher
forall x. Rep RegisterPublisher x -> RegisterPublisher
forall x. RegisterPublisher -> Rep RegisterPublisher x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterPublisher x -> RegisterPublisher
$cfrom :: forall x. RegisterPublisher -> Rep RegisterPublisher x
Prelude.Generic)

-- |
-- Create a value of 'RegisterPublisher' 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:
--
-- 'connectionArn', 'registerPublisher_connectionArn' - If you are using a Bitbucket or GitHub account for identity
-- verification, the Amazon Resource Name (ARN) for your connection to that
-- account.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/publish-extension.html#publish-extension-prereqs Registering your account to publish CloudFormation extensions>
-- in the /CloudFormation CLI User Guide/.
--
-- 'acceptTermsAndConditions', 'registerPublisher_acceptTermsAndConditions' - Whether you accept the
-- <https://cloudformation-registry-documents.s3.amazonaws.com/Terms_and_Conditions_for_AWS_CloudFormation_Registry_Publishers.pdf Terms and Conditions>
-- for publishing extensions in the CloudFormation registry. You must
-- accept the terms and conditions in order to register to publish public
-- extensions to the CloudFormation registry.
--
-- The default is @false@.
newRegisterPublisher ::
  RegisterPublisher
newRegisterPublisher :: RegisterPublisher
newRegisterPublisher =
  RegisterPublisher' :: Maybe Text -> Maybe Bool -> RegisterPublisher
RegisterPublisher'
    { $sel:connectionArn:RegisterPublisher' :: Maybe Text
connectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:acceptTermsAndConditions:RegisterPublisher' :: Maybe Bool
acceptTermsAndConditions = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | If you are using a Bitbucket or GitHub account for identity
-- verification, the Amazon Resource Name (ARN) for your connection to that
-- account.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/publish-extension.html#publish-extension-prereqs Registering your account to publish CloudFormation extensions>
-- in the /CloudFormation CLI User Guide/.
registerPublisher_connectionArn :: Lens.Lens' RegisterPublisher (Prelude.Maybe Prelude.Text)
registerPublisher_connectionArn :: (Maybe Text -> f (Maybe Text))
-> RegisterPublisher -> f RegisterPublisher
registerPublisher_connectionArn = (RegisterPublisher -> Maybe Text)
-> (RegisterPublisher -> Maybe Text -> RegisterPublisher)
-> Lens
     RegisterPublisher RegisterPublisher (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterPublisher' {Maybe Text
connectionArn :: Maybe Text
$sel:connectionArn:RegisterPublisher' :: RegisterPublisher -> Maybe Text
connectionArn} -> Maybe Text
connectionArn) (\s :: RegisterPublisher
s@RegisterPublisher' {} Maybe Text
a -> RegisterPublisher
s {$sel:connectionArn:RegisterPublisher' :: Maybe Text
connectionArn = Maybe Text
a} :: RegisterPublisher)

-- | Whether you accept the
-- <https://cloudformation-registry-documents.s3.amazonaws.com/Terms_and_Conditions_for_AWS_CloudFormation_Registry_Publishers.pdf Terms and Conditions>
-- for publishing extensions in the CloudFormation registry. You must
-- accept the terms and conditions in order to register to publish public
-- extensions to the CloudFormation registry.
--
-- The default is @false@.
registerPublisher_acceptTermsAndConditions :: Lens.Lens' RegisterPublisher (Prelude.Maybe Prelude.Bool)
registerPublisher_acceptTermsAndConditions :: (Maybe Bool -> f (Maybe Bool))
-> RegisterPublisher -> f RegisterPublisher
registerPublisher_acceptTermsAndConditions = (RegisterPublisher -> Maybe Bool)
-> (RegisterPublisher -> Maybe Bool -> RegisterPublisher)
-> Lens
     RegisterPublisher RegisterPublisher (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterPublisher' {Maybe Bool
acceptTermsAndConditions :: Maybe Bool
$sel:acceptTermsAndConditions:RegisterPublisher' :: RegisterPublisher -> Maybe Bool
acceptTermsAndConditions} -> Maybe Bool
acceptTermsAndConditions) (\s :: RegisterPublisher
s@RegisterPublisher' {} Maybe Bool
a -> RegisterPublisher
s {$sel:acceptTermsAndConditions:RegisterPublisher' :: Maybe Bool
acceptTermsAndConditions = Maybe Bool
a} :: RegisterPublisher)

instance Core.AWSRequest RegisterPublisher where
  type
    AWSResponse RegisterPublisher =
      RegisterPublisherResponse
  request :: RegisterPublisher -> Request RegisterPublisher
request = Service -> RegisterPublisher -> Request RegisterPublisher
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy RegisterPublisher
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterPublisher)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse RegisterPublisher))
-> Logger
-> Service
-> Proxy RegisterPublisher
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterPublisher)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"RegisterPublisherResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> RegisterPublisherResponse
RegisterPublisherResponse'
            (Maybe Text -> Int -> RegisterPublisherResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RegisterPublisherResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PublisherId")
            Either String (Int -> RegisterPublisherResponse)
-> Either String Int -> Either String RegisterPublisherResponse
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 RegisterPublisher

instance Prelude.NFData RegisterPublisher

instance Core.ToHeaders RegisterPublisher where
  toHeaders :: RegisterPublisher -> ResponseHeaders
toHeaders = ResponseHeaders -> RegisterPublisher -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery RegisterPublisher where
  toQuery :: RegisterPublisher -> QueryString
toQuery RegisterPublisher' {Maybe Bool
Maybe Text
acceptTermsAndConditions :: Maybe Bool
connectionArn :: Maybe Text
$sel:acceptTermsAndConditions:RegisterPublisher' :: RegisterPublisher -> Maybe Bool
$sel:connectionArn:RegisterPublisher' :: RegisterPublisher -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"RegisterPublisher" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"ConnectionArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
connectionArn,
        ByteString
"AcceptTermsAndConditions"
          ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
acceptTermsAndConditions
      ]

-- | /See:/ 'newRegisterPublisherResponse' smart constructor.
data RegisterPublisherResponse = RegisterPublisherResponse'
  { -- | The ID assigned this account by CloudFormation for publishing
    -- extensions.
    RegisterPublisherResponse -> Maybe Text
publisherId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    RegisterPublisherResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RegisterPublisherResponse -> RegisterPublisherResponse -> Bool
(RegisterPublisherResponse -> RegisterPublisherResponse -> Bool)
-> (RegisterPublisherResponse -> RegisterPublisherResponse -> Bool)
-> Eq RegisterPublisherResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterPublisherResponse -> RegisterPublisherResponse -> Bool
$c/= :: RegisterPublisherResponse -> RegisterPublisherResponse -> Bool
== :: RegisterPublisherResponse -> RegisterPublisherResponse -> Bool
$c== :: RegisterPublisherResponse -> RegisterPublisherResponse -> Bool
Prelude.Eq, ReadPrec [RegisterPublisherResponse]
ReadPrec RegisterPublisherResponse
Int -> ReadS RegisterPublisherResponse
ReadS [RegisterPublisherResponse]
(Int -> ReadS RegisterPublisherResponse)
-> ReadS [RegisterPublisherResponse]
-> ReadPrec RegisterPublisherResponse
-> ReadPrec [RegisterPublisherResponse]
-> Read RegisterPublisherResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterPublisherResponse]
$creadListPrec :: ReadPrec [RegisterPublisherResponse]
readPrec :: ReadPrec RegisterPublisherResponse
$creadPrec :: ReadPrec RegisterPublisherResponse
readList :: ReadS [RegisterPublisherResponse]
$creadList :: ReadS [RegisterPublisherResponse]
readsPrec :: Int -> ReadS RegisterPublisherResponse
$creadsPrec :: Int -> ReadS RegisterPublisherResponse
Prelude.Read, Int -> RegisterPublisherResponse -> ShowS
[RegisterPublisherResponse] -> ShowS
RegisterPublisherResponse -> String
(Int -> RegisterPublisherResponse -> ShowS)
-> (RegisterPublisherResponse -> String)
-> ([RegisterPublisherResponse] -> ShowS)
-> Show RegisterPublisherResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterPublisherResponse] -> ShowS
$cshowList :: [RegisterPublisherResponse] -> ShowS
show :: RegisterPublisherResponse -> String
$cshow :: RegisterPublisherResponse -> String
showsPrec :: Int -> RegisterPublisherResponse -> ShowS
$cshowsPrec :: Int -> RegisterPublisherResponse -> ShowS
Prelude.Show, (forall x.
 RegisterPublisherResponse -> Rep RegisterPublisherResponse x)
-> (forall x.
    Rep RegisterPublisherResponse x -> RegisterPublisherResponse)
-> Generic RegisterPublisherResponse
forall x.
Rep RegisterPublisherResponse x -> RegisterPublisherResponse
forall x.
RegisterPublisherResponse -> Rep RegisterPublisherResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterPublisherResponse x -> RegisterPublisherResponse
$cfrom :: forall x.
RegisterPublisherResponse -> Rep RegisterPublisherResponse x
Prelude.Generic)

-- |
-- Create a value of 'RegisterPublisherResponse' 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:
--
-- 'publisherId', 'registerPublisherResponse_publisherId' - The ID assigned this account by CloudFormation for publishing
-- extensions.
--
-- 'httpStatus', 'registerPublisherResponse_httpStatus' - The response's http status code.
newRegisterPublisherResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterPublisherResponse
newRegisterPublisherResponse :: Int -> RegisterPublisherResponse
newRegisterPublisherResponse Int
pHttpStatus_ =
  RegisterPublisherResponse' :: Maybe Text -> Int -> RegisterPublisherResponse
RegisterPublisherResponse'
    { $sel:publisherId:RegisterPublisherResponse' :: Maybe Text
publisherId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RegisterPublisherResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID assigned this account by CloudFormation for publishing
-- extensions.
registerPublisherResponse_publisherId :: Lens.Lens' RegisterPublisherResponse (Prelude.Maybe Prelude.Text)
registerPublisherResponse_publisherId :: (Maybe Text -> f (Maybe Text))
-> RegisterPublisherResponse -> f RegisterPublisherResponse
registerPublisherResponse_publisherId = (RegisterPublisherResponse -> Maybe Text)
-> (RegisterPublisherResponse
    -> Maybe Text -> RegisterPublisherResponse)
-> Lens
     RegisterPublisherResponse
     RegisterPublisherResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterPublisherResponse' {Maybe Text
publisherId :: Maybe Text
$sel:publisherId:RegisterPublisherResponse' :: RegisterPublisherResponse -> Maybe Text
publisherId} -> Maybe Text
publisherId) (\s :: RegisterPublisherResponse
s@RegisterPublisherResponse' {} Maybe Text
a -> RegisterPublisherResponse
s {$sel:publisherId:RegisterPublisherResponse' :: Maybe Text
publisherId = Maybe Text
a} :: RegisterPublisherResponse)

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

instance Prelude.NFData RegisterPublisherResponse