{-# 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.Route53RecoveryReadiness.CreateCrossAccountAuthorization
-- 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)
--
-- Create a new cross account readiness authorization.
module Amazonka.Route53RecoveryReadiness.CreateCrossAccountAuthorization
  ( -- * Creating a Request
    CreateCrossAccountAuthorization (..),
    newCreateCrossAccountAuthorization,

    -- * Request Lenses
    createCrossAccountAuthorization_crossAccountAuthorization,

    -- * Destructuring the Response
    CreateCrossAccountAuthorizationResponse (..),
    newCreateCrossAccountAuthorizationResponse,

    -- * Response Lenses
    createCrossAccountAuthorizationResponse_crossAccountAuthorization,
    createCrossAccountAuthorizationResponse_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.Route53RecoveryReadiness.Types

-- | The cross account authorization
--
-- /See:/ 'newCreateCrossAccountAuthorization' smart constructor.
data CreateCrossAccountAuthorization = CreateCrossAccountAuthorization'
  { -- | The cross account authorization
    CreateCrossAccountAuthorization -> Text
crossAccountAuthorization :: Prelude.Text
  }
  deriving (CreateCrossAccountAuthorization
-> CreateCrossAccountAuthorization -> Bool
(CreateCrossAccountAuthorization
 -> CreateCrossAccountAuthorization -> Bool)
-> (CreateCrossAccountAuthorization
    -> CreateCrossAccountAuthorization -> Bool)
-> Eq CreateCrossAccountAuthorization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCrossAccountAuthorization
-> CreateCrossAccountAuthorization -> Bool
$c/= :: CreateCrossAccountAuthorization
-> CreateCrossAccountAuthorization -> Bool
== :: CreateCrossAccountAuthorization
-> CreateCrossAccountAuthorization -> Bool
$c== :: CreateCrossAccountAuthorization
-> CreateCrossAccountAuthorization -> Bool
Prelude.Eq, ReadPrec [CreateCrossAccountAuthorization]
ReadPrec CreateCrossAccountAuthorization
Int -> ReadS CreateCrossAccountAuthorization
ReadS [CreateCrossAccountAuthorization]
(Int -> ReadS CreateCrossAccountAuthorization)
-> ReadS [CreateCrossAccountAuthorization]
-> ReadPrec CreateCrossAccountAuthorization
-> ReadPrec [CreateCrossAccountAuthorization]
-> Read CreateCrossAccountAuthorization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCrossAccountAuthorization]
$creadListPrec :: ReadPrec [CreateCrossAccountAuthorization]
readPrec :: ReadPrec CreateCrossAccountAuthorization
$creadPrec :: ReadPrec CreateCrossAccountAuthorization
readList :: ReadS [CreateCrossAccountAuthorization]
$creadList :: ReadS [CreateCrossAccountAuthorization]
readsPrec :: Int -> ReadS CreateCrossAccountAuthorization
$creadsPrec :: Int -> ReadS CreateCrossAccountAuthorization
Prelude.Read, Int -> CreateCrossAccountAuthorization -> ShowS
[CreateCrossAccountAuthorization] -> ShowS
CreateCrossAccountAuthorization -> String
(Int -> CreateCrossAccountAuthorization -> ShowS)
-> (CreateCrossAccountAuthorization -> String)
-> ([CreateCrossAccountAuthorization] -> ShowS)
-> Show CreateCrossAccountAuthorization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCrossAccountAuthorization] -> ShowS
$cshowList :: [CreateCrossAccountAuthorization] -> ShowS
show :: CreateCrossAccountAuthorization -> String
$cshow :: CreateCrossAccountAuthorization -> String
showsPrec :: Int -> CreateCrossAccountAuthorization -> ShowS
$cshowsPrec :: Int -> CreateCrossAccountAuthorization -> ShowS
Prelude.Show, (forall x.
 CreateCrossAccountAuthorization
 -> Rep CreateCrossAccountAuthorization x)
-> (forall x.
    Rep CreateCrossAccountAuthorization x
    -> CreateCrossAccountAuthorization)
-> Generic CreateCrossAccountAuthorization
forall x.
Rep CreateCrossAccountAuthorization x
-> CreateCrossAccountAuthorization
forall x.
CreateCrossAccountAuthorization
-> Rep CreateCrossAccountAuthorization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCrossAccountAuthorization x
-> CreateCrossAccountAuthorization
$cfrom :: forall x.
CreateCrossAccountAuthorization
-> Rep CreateCrossAccountAuthorization x
Prelude.Generic)

-- |
-- Create a value of 'CreateCrossAccountAuthorization' 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:
--
-- 'crossAccountAuthorization', 'createCrossAccountAuthorization_crossAccountAuthorization' - The cross account authorization
newCreateCrossAccountAuthorization ::
  -- | 'crossAccountAuthorization'
  Prelude.Text ->
  CreateCrossAccountAuthorization
newCreateCrossAccountAuthorization :: Text -> CreateCrossAccountAuthorization
newCreateCrossAccountAuthorization
  Text
pCrossAccountAuthorization_ =
    CreateCrossAccountAuthorization' :: Text -> CreateCrossAccountAuthorization
CreateCrossAccountAuthorization'
      { $sel:crossAccountAuthorization:CreateCrossAccountAuthorization' :: Text
crossAccountAuthorization =
          Text
pCrossAccountAuthorization_
      }

-- | The cross account authorization
createCrossAccountAuthorization_crossAccountAuthorization :: Lens.Lens' CreateCrossAccountAuthorization Prelude.Text
createCrossAccountAuthorization_crossAccountAuthorization :: (Text -> f Text)
-> CreateCrossAccountAuthorization
-> f CreateCrossAccountAuthorization
createCrossAccountAuthorization_crossAccountAuthorization = (CreateCrossAccountAuthorization -> Text)
-> (CreateCrossAccountAuthorization
    -> Text -> CreateCrossAccountAuthorization)
-> Lens
     CreateCrossAccountAuthorization
     CreateCrossAccountAuthorization
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCrossAccountAuthorization' {Text
crossAccountAuthorization :: Text
$sel:crossAccountAuthorization:CreateCrossAccountAuthorization' :: CreateCrossAccountAuthorization -> Text
crossAccountAuthorization} -> Text
crossAccountAuthorization) (\s :: CreateCrossAccountAuthorization
s@CreateCrossAccountAuthorization' {} Text
a -> CreateCrossAccountAuthorization
s {$sel:crossAccountAuthorization:CreateCrossAccountAuthorization' :: Text
crossAccountAuthorization = Text
a} :: CreateCrossAccountAuthorization)

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

instance
  Prelude.NFData
    CreateCrossAccountAuthorization

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

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

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

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

-- |
-- Create a value of 'CreateCrossAccountAuthorizationResponse' 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:
--
-- 'crossAccountAuthorization', 'createCrossAccountAuthorizationResponse_crossAccountAuthorization' - The cross account authorization
--
-- 'httpStatus', 'createCrossAccountAuthorizationResponse_httpStatus' - The response's http status code.
newCreateCrossAccountAuthorizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateCrossAccountAuthorizationResponse
newCreateCrossAccountAuthorizationResponse :: Int -> CreateCrossAccountAuthorizationResponse
newCreateCrossAccountAuthorizationResponse
  Int
pHttpStatus_ =
    CreateCrossAccountAuthorizationResponse' :: Maybe Text -> Int -> CreateCrossAccountAuthorizationResponse
CreateCrossAccountAuthorizationResponse'
      { $sel:crossAccountAuthorization:CreateCrossAccountAuthorizationResponse' :: Maybe Text
crossAccountAuthorization =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:CreateCrossAccountAuthorizationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The cross account authorization
createCrossAccountAuthorizationResponse_crossAccountAuthorization :: Lens.Lens' CreateCrossAccountAuthorizationResponse (Prelude.Maybe Prelude.Text)
createCrossAccountAuthorizationResponse_crossAccountAuthorization :: (Maybe Text -> f (Maybe Text))
-> CreateCrossAccountAuthorizationResponse
-> f CreateCrossAccountAuthorizationResponse
createCrossAccountAuthorizationResponse_crossAccountAuthorization = (CreateCrossAccountAuthorizationResponse -> Maybe Text)
-> (CreateCrossAccountAuthorizationResponse
    -> Maybe Text -> CreateCrossAccountAuthorizationResponse)
-> Lens
     CreateCrossAccountAuthorizationResponse
     CreateCrossAccountAuthorizationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCrossAccountAuthorizationResponse' {Maybe Text
crossAccountAuthorization :: Maybe Text
$sel:crossAccountAuthorization:CreateCrossAccountAuthorizationResponse' :: CreateCrossAccountAuthorizationResponse -> Maybe Text
crossAccountAuthorization} -> Maybe Text
crossAccountAuthorization) (\s :: CreateCrossAccountAuthorizationResponse
s@CreateCrossAccountAuthorizationResponse' {} Maybe Text
a -> CreateCrossAccountAuthorizationResponse
s {$sel:crossAccountAuthorization:CreateCrossAccountAuthorizationResponse' :: Maybe Text
crossAccountAuthorization = Maybe Text
a} :: CreateCrossAccountAuthorizationResponse)

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

instance
  Prelude.NFData
    CreateCrossAccountAuthorizationResponse