{-# 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.BackupGateway.CreateGateway
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a backup gateway. After you create a gateway, you can associate
-- it with a server using the @AssociateGatewayToServer@ operation.
module Amazonka.BackupGateway.CreateGateway
  ( -- * Creating a Request
    CreateGateway (..),
    newCreateGateway,

    -- * Request Lenses
    createGateway_tags,
    createGateway_activationKey,
    createGateway_gatewayDisplayName,
    createGateway_gatewayType,

    -- * Destructuring the Response
    CreateGatewayResponse (..),
    newCreateGatewayResponse,

    -- * Response Lenses
    createGatewayResponse_gatewayArn,
    createGatewayResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateGateway' smart constructor.
data CreateGateway = CreateGateway'
  { -- | A list of up to 50 tags to assign to the gateway. Each tag is a
    -- key-value pair.
    CreateGateway -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The activation key of the created gateway.
    CreateGateway -> Text
activationKey :: Prelude.Text,
    -- | The display name of the created gateway.
    CreateGateway -> Text
gatewayDisplayName :: Prelude.Text,
    -- | The type of created gateway.
    CreateGateway -> GatewayType
gatewayType :: GatewayType
  }
  deriving (CreateGateway -> CreateGateway -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGateway -> CreateGateway -> Bool
$c/= :: CreateGateway -> CreateGateway -> Bool
== :: CreateGateway -> CreateGateway -> Bool
$c== :: CreateGateway -> CreateGateway -> Bool
Prelude.Eq, ReadPrec [CreateGateway]
ReadPrec CreateGateway
Int -> ReadS CreateGateway
ReadS [CreateGateway]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGateway]
$creadListPrec :: ReadPrec [CreateGateway]
readPrec :: ReadPrec CreateGateway
$creadPrec :: ReadPrec CreateGateway
readList :: ReadS [CreateGateway]
$creadList :: ReadS [CreateGateway]
readsPrec :: Int -> ReadS CreateGateway
$creadsPrec :: Int -> ReadS CreateGateway
Prelude.Read, Int -> CreateGateway -> ShowS
[CreateGateway] -> ShowS
CreateGateway -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGateway] -> ShowS
$cshowList :: [CreateGateway] -> ShowS
show :: CreateGateway -> String
$cshow :: CreateGateway -> String
showsPrec :: Int -> CreateGateway -> ShowS
$cshowsPrec :: Int -> CreateGateway -> ShowS
Prelude.Show, forall x. Rep CreateGateway x -> CreateGateway
forall x. CreateGateway -> Rep CreateGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGateway x -> CreateGateway
$cfrom :: forall x. CreateGateway -> Rep CreateGateway x
Prelude.Generic)

-- |
-- Create a value of 'CreateGateway' 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:
--
-- 'tags', 'createGateway_tags' - A list of up to 50 tags to assign to the gateway. Each tag is a
-- key-value pair.
--
-- 'activationKey', 'createGateway_activationKey' - The activation key of the created gateway.
--
-- 'gatewayDisplayName', 'createGateway_gatewayDisplayName' - The display name of the created gateway.
--
-- 'gatewayType', 'createGateway_gatewayType' - The type of created gateway.
newCreateGateway ::
  -- | 'activationKey'
  Prelude.Text ->
  -- | 'gatewayDisplayName'
  Prelude.Text ->
  -- | 'gatewayType'
  GatewayType ->
  CreateGateway
newCreateGateway :: Text -> Text -> GatewayType -> CreateGateway
newCreateGateway
  Text
pActivationKey_
  Text
pGatewayDisplayName_
  GatewayType
pGatewayType_ =
    CreateGateway'
      { $sel:tags:CreateGateway' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:activationKey:CreateGateway' :: Text
activationKey = Text
pActivationKey_,
        $sel:gatewayDisplayName:CreateGateway' :: Text
gatewayDisplayName = Text
pGatewayDisplayName_,
        $sel:gatewayType:CreateGateway' :: GatewayType
gatewayType = GatewayType
pGatewayType_
      }

-- | A list of up to 50 tags to assign to the gateway. Each tag is a
-- key-value pair.
createGateway_tags :: Lens.Lens' CreateGateway (Prelude.Maybe [Tag])
createGateway_tags :: Lens' CreateGateway (Maybe [Tag])
createGateway_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateGateway' :: CreateGateway -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateGateway
s@CreateGateway' {} Maybe [Tag]
a -> CreateGateway
s {$sel:tags:CreateGateway' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateGateway) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The activation key of the created gateway.
createGateway_activationKey :: Lens.Lens' CreateGateway Prelude.Text
createGateway_activationKey :: Lens' CreateGateway Text
createGateway_activationKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {Text
activationKey :: Text
$sel:activationKey:CreateGateway' :: CreateGateway -> Text
activationKey} -> Text
activationKey) (\s :: CreateGateway
s@CreateGateway' {} Text
a -> CreateGateway
s {$sel:activationKey:CreateGateway' :: Text
activationKey = Text
a} :: CreateGateway)

-- | The display name of the created gateway.
createGateway_gatewayDisplayName :: Lens.Lens' CreateGateway Prelude.Text
createGateway_gatewayDisplayName :: Lens' CreateGateway Text
createGateway_gatewayDisplayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {Text
gatewayDisplayName :: Text
$sel:gatewayDisplayName:CreateGateway' :: CreateGateway -> Text
gatewayDisplayName} -> Text
gatewayDisplayName) (\s :: CreateGateway
s@CreateGateway' {} Text
a -> CreateGateway
s {$sel:gatewayDisplayName:CreateGateway' :: Text
gatewayDisplayName = Text
a} :: CreateGateway)

-- | The type of created gateway.
createGateway_gatewayType :: Lens.Lens' CreateGateway GatewayType
createGateway_gatewayType :: Lens' CreateGateway GatewayType
createGateway_gatewayType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {GatewayType
gatewayType :: GatewayType
$sel:gatewayType:CreateGateway' :: CreateGateway -> GatewayType
gatewayType} -> GatewayType
gatewayType) (\s :: CreateGateway
s@CreateGateway' {} GatewayType
a -> CreateGateway
s {$sel:gatewayType:CreateGateway' :: GatewayType
gatewayType = GatewayType
a} :: CreateGateway)

instance Core.AWSRequest CreateGateway where
  type
    AWSResponse CreateGateway =
      CreateGatewayResponse
  request :: (Service -> Service) -> CreateGateway -> Request CreateGateway
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 CreateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateGateway)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> CreateGatewayResponse
CreateGatewayResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"GatewayArn")
            forall (f :: * -> *) a b. Applicative f => 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 CreateGateway where
  hashWithSalt :: Int -> CreateGateway -> Int
hashWithSalt Int
_salt CreateGateway' {Maybe [Tag]
Text
GatewayType
gatewayType :: GatewayType
gatewayDisplayName :: Text
activationKey :: Text
tags :: Maybe [Tag]
$sel:gatewayType:CreateGateway' :: CreateGateway -> GatewayType
$sel:gatewayDisplayName:CreateGateway' :: CreateGateway -> Text
$sel:activationKey:CreateGateway' :: CreateGateway -> Text
$sel:tags:CreateGateway' :: CreateGateway -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
activationKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayDisplayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GatewayType
gatewayType

instance Prelude.NFData CreateGateway where
  rnf :: CreateGateway -> ()
rnf CreateGateway' {Maybe [Tag]
Text
GatewayType
gatewayType :: GatewayType
gatewayDisplayName :: Text
activationKey :: Text
tags :: Maybe [Tag]
$sel:gatewayType:CreateGateway' :: CreateGateway -> GatewayType
$sel:gatewayDisplayName:CreateGateway' :: CreateGateway -> Text
$sel:activationKey:CreateGateway' :: CreateGateway -> Text
$sel:tags:CreateGateway' :: CreateGateway -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
activationKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
gatewayDisplayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GatewayType
gatewayType

instance Data.ToHeaders CreateGateway where
  toHeaders :: CreateGateway -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"BackupOnPremises_v20210101.CreateGateway" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateGateway where
  toJSON :: CreateGateway -> Value
toJSON CreateGateway' {Maybe [Tag]
Text
GatewayType
gatewayType :: GatewayType
gatewayDisplayName :: Text
activationKey :: Text
tags :: Maybe [Tag]
$sel:gatewayType:CreateGateway' :: CreateGateway -> GatewayType
$sel:gatewayDisplayName:CreateGateway' :: CreateGateway -> Text
$sel:activationKey:CreateGateway' :: CreateGateway -> Text
$sel:tags:CreateGateway' :: CreateGateway -> Maybe [Tag]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"ActivationKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
activationKey),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"GatewayDisplayName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gatewayDisplayName),
            forall a. a -> Maybe a
Prelude.Just (Key
"GatewayType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GatewayType
gatewayType)
          ]
      )

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

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

-- | /See:/ 'newCreateGatewayResponse' smart constructor.
data CreateGatewayResponse = CreateGatewayResponse'
  { -- | The Amazon Resource Name (ARN) of the gateway you create.
    CreateGatewayResponse -> Maybe Text
gatewayArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateGatewayResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateGatewayResponse -> CreateGatewayResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
$c/= :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
== :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
$c== :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
Prelude.Eq, ReadPrec [CreateGatewayResponse]
ReadPrec CreateGatewayResponse
Int -> ReadS CreateGatewayResponse
ReadS [CreateGatewayResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGatewayResponse]
$creadListPrec :: ReadPrec [CreateGatewayResponse]
readPrec :: ReadPrec CreateGatewayResponse
$creadPrec :: ReadPrec CreateGatewayResponse
readList :: ReadS [CreateGatewayResponse]
$creadList :: ReadS [CreateGatewayResponse]
readsPrec :: Int -> ReadS CreateGatewayResponse
$creadsPrec :: Int -> ReadS CreateGatewayResponse
Prelude.Read, Int -> CreateGatewayResponse -> ShowS
[CreateGatewayResponse] -> ShowS
CreateGatewayResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGatewayResponse] -> ShowS
$cshowList :: [CreateGatewayResponse] -> ShowS
show :: CreateGatewayResponse -> String
$cshow :: CreateGatewayResponse -> String
showsPrec :: Int -> CreateGatewayResponse -> ShowS
$cshowsPrec :: Int -> CreateGatewayResponse -> ShowS
Prelude.Show, forall x. Rep CreateGatewayResponse x -> CreateGatewayResponse
forall x. CreateGatewayResponse -> Rep CreateGatewayResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGatewayResponse x -> CreateGatewayResponse
$cfrom :: forall x. CreateGatewayResponse -> Rep CreateGatewayResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateGatewayResponse' 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:
--
-- 'gatewayArn', 'createGatewayResponse_gatewayArn' - The Amazon Resource Name (ARN) of the gateway you create.
--
-- 'httpStatus', 'createGatewayResponse_httpStatus' - The response's http status code.
newCreateGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateGatewayResponse
newCreateGatewayResponse :: Int -> CreateGatewayResponse
newCreateGatewayResponse Int
pHttpStatus_ =
  CreateGatewayResponse'
    { $sel:gatewayArn:CreateGatewayResponse' :: Maybe Text
gatewayArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the gateway you create.
createGatewayResponse_gatewayArn :: Lens.Lens' CreateGatewayResponse (Prelude.Maybe Prelude.Text)
createGatewayResponse_gatewayArn :: Lens' CreateGatewayResponse (Maybe Text)
createGatewayResponse_gatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGatewayResponse' {Maybe Text
gatewayArn :: Maybe Text
$sel:gatewayArn:CreateGatewayResponse' :: CreateGatewayResponse -> Maybe Text
gatewayArn} -> Maybe Text
gatewayArn) (\s :: CreateGatewayResponse
s@CreateGatewayResponse' {} Maybe Text
a -> CreateGatewayResponse
s {$sel:gatewayArn:CreateGatewayResponse' :: Maybe Text
gatewayArn = Maybe Text
a} :: CreateGatewayResponse)

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

instance Prelude.NFData CreateGatewayResponse where
  rnf :: CreateGatewayResponse -> ()
rnf CreateGatewayResponse' {Int
Maybe Text
httpStatus :: Int
gatewayArn :: Maybe Text
$sel:httpStatus:CreateGatewayResponse' :: CreateGatewayResponse -> Int
$sel:gatewayArn:CreateGatewayResponse' :: CreateGatewayResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gatewayArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus