{-# 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.NetworkManager.CreateGlobalNetwork
-- 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)
--
-- Creates a new, empty global network.
module Amazonka.NetworkManager.CreateGlobalNetwork
  ( -- * Creating a Request
    CreateGlobalNetwork (..),
    newCreateGlobalNetwork,

    -- * Request Lenses
    createGlobalNetwork_description,
    createGlobalNetwork_tags,

    -- * Destructuring the Response
    CreateGlobalNetworkResponse (..),
    newCreateGlobalNetworkResponse,

    -- * Response Lenses
    createGlobalNetworkResponse_globalNetwork,
    createGlobalNetworkResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateGlobalNetwork' smart constructor.
data CreateGlobalNetwork = CreateGlobalNetwork'
  { -- | A description of the global network.
    --
    -- Length Constraints: Maximum length of 256 characters.
    CreateGlobalNetwork -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags to apply to the resource during creation.
    CreateGlobalNetwork -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (CreateGlobalNetwork -> CreateGlobalNetwork -> Bool
(CreateGlobalNetwork -> CreateGlobalNetwork -> Bool)
-> (CreateGlobalNetwork -> CreateGlobalNetwork -> Bool)
-> Eq CreateGlobalNetwork
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGlobalNetwork -> CreateGlobalNetwork -> Bool
$c/= :: CreateGlobalNetwork -> CreateGlobalNetwork -> Bool
== :: CreateGlobalNetwork -> CreateGlobalNetwork -> Bool
$c== :: CreateGlobalNetwork -> CreateGlobalNetwork -> Bool
Prelude.Eq, ReadPrec [CreateGlobalNetwork]
ReadPrec CreateGlobalNetwork
Int -> ReadS CreateGlobalNetwork
ReadS [CreateGlobalNetwork]
(Int -> ReadS CreateGlobalNetwork)
-> ReadS [CreateGlobalNetwork]
-> ReadPrec CreateGlobalNetwork
-> ReadPrec [CreateGlobalNetwork]
-> Read CreateGlobalNetwork
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGlobalNetwork]
$creadListPrec :: ReadPrec [CreateGlobalNetwork]
readPrec :: ReadPrec CreateGlobalNetwork
$creadPrec :: ReadPrec CreateGlobalNetwork
readList :: ReadS [CreateGlobalNetwork]
$creadList :: ReadS [CreateGlobalNetwork]
readsPrec :: Int -> ReadS CreateGlobalNetwork
$creadsPrec :: Int -> ReadS CreateGlobalNetwork
Prelude.Read, Int -> CreateGlobalNetwork -> ShowS
[CreateGlobalNetwork] -> ShowS
CreateGlobalNetwork -> String
(Int -> CreateGlobalNetwork -> ShowS)
-> (CreateGlobalNetwork -> String)
-> ([CreateGlobalNetwork] -> ShowS)
-> Show CreateGlobalNetwork
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGlobalNetwork] -> ShowS
$cshowList :: [CreateGlobalNetwork] -> ShowS
show :: CreateGlobalNetwork -> String
$cshow :: CreateGlobalNetwork -> String
showsPrec :: Int -> CreateGlobalNetwork -> ShowS
$cshowsPrec :: Int -> CreateGlobalNetwork -> ShowS
Prelude.Show, (forall x. CreateGlobalNetwork -> Rep CreateGlobalNetwork x)
-> (forall x. Rep CreateGlobalNetwork x -> CreateGlobalNetwork)
-> Generic CreateGlobalNetwork
forall x. Rep CreateGlobalNetwork x -> CreateGlobalNetwork
forall x. CreateGlobalNetwork -> Rep CreateGlobalNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGlobalNetwork x -> CreateGlobalNetwork
$cfrom :: forall x. CreateGlobalNetwork -> Rep CreateGlobalNetwork x
Prelude.Generic)

-- |
-- Create a value of 'CreateGlobalNetwork' 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:
--
-- 'description', 'createGlobalNetwork_description' - A description of the global network.
--
-- Length Constraints: Maximum length of 256 characters.
--
-- 'tags', 'createGlobalNetwork_tags' - The tags to apply to the resource during creation.
newCreateGlobalNetwork ::
  CreateGlobalNetwork
newCreateGlobalNetwork :: CreateGlobalNetwork
newCreateGlobalNetwork =
  CreateGlobalNetwork' :: Maybe Text -> Maybe [Tag] -> CreateGlobalNetwork
CreateGlobalNetwork'
    { $sel:description:CreateGlobalNetwork' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateGlobalNetwork' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | A description of the global network.
--
-- Length Constraints: Maximum length of 256 characters.
createGlobalNetwork_description :: Lens.Lens' CreateGlobalNetwork (Prelude.Maybe Prelude.Text)
createGlobalNetwork_description :: (Maybe Text -> f (Maybe Text))
-> CreateGlobalNetwork -> f CreateGlobalNetwork
createGlobalNetwork_description = (CreateGlobalNetwork -> Maybe Text)
-> (CreateGlobalNetwork -> Maybe Text -> CreateGlobalNetwork)
-> Lens
     CreateGlobalNetwork CreateGlobalNetwork (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalNetwork' {Maybe Text
description :: Maybe Text
$sel:description:CreateGlobalNetwork' :: CreateGlobalNetwork -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateGlobalNetwork
s@CreateGlobalNetwork' {} Maybe Text
a -> CreateGlobalNetwork
s {$sel:description:CreateGlobalNetwork' :: Maybe Text
description = Maybe Text
a} :: CreateGlobalNetwork)

-- | The tags to apply to the resource during creation.
createGlobalNetwork_tags :: Lens.Lens' CreateGlobalNetwork (Prelude.Maybe [Tag])
createGlobalNetwork_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateGlobalNetwork -> f CreateGlobalNetwork
createGlobalNetwork_tags = (CreateGlobalNetwork -> Maybe [Tag])
-> (CreateGlobalNetwork -> Maybe [Tag] -> CreateGlobalNetwork)
-> Lens
     CreateGlobalNetwork CreateGlobalNetwork (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalNetwork' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateGlobalNetwork' :: CreateGlobalNetwork -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateGlobalNetwork
s@CreateGlobalNetwork' {} Maybe [Tag]
a -> CreateGlobalNetwork
s {$sel:tags:CreateGlobalNetwork' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateGlobalNetwork) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateGlobalNetwork -> f CreateGlobalNetwork)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateGlobalNetwork
-> f CreateGlobalNetwork
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateGlobalNetwork where
  type
    AWSResponse CreateGlobalNetwork =
      CreateGlobalNetworkResponse
  request :: CreateGlobalNetwork -> Request CreateGlobalNetwork
request = Service -> CreateGlobalNetwork -> Request CreateGlobalNetwork
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGlobalNetwork)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateGlobalNetwork))
-> Logger
-> Service
-> Proxy CreateGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateGlobalNetwork)))
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 GlobalNetwork -> Int -> CreateGlobalNetworkResponse
CreateGlobalNetworkResponse'
            (Maybe GlobalNetwork -> Int -> CreateGlobalNetworkResponse)
-> Either String (Maybe GlobalNetwork)
-> Either String (Int -> CreateGlobalNetworkResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GlobalNetwork)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GlobalNetwork")
            Either String (Int -> CreateGlobalNetworkResponse)
-> Either String Int -> Either String CreateGlobalNetworkResponse
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 CreateGlobalNetwork

instance Prelude.NFData CreateGlobalNetwork

instance Core.ToHeaders CreateGlobalNetwork where
  toHeaders :: CreateGlobalNetwork -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateGlobalNetwork -> 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 CreateGlobalNetwork where
  toJSON :: CreateGlobalNetwork -> Value
toJSON CreateGlobalNetwork' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
description :: Maybe Text
$sel:tags:CreateGlobalNetwork' :: CreateGlobalNetwork -> Maybe [Tag]
$sel:description:CreateGlobalNetwork' :: CreateGlobalNetwork -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateGlobalNetworkResponse' 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:
--
-- 'globalNetwork', 'createGlobalNetworkResponse_globalNetwork' - Information about the global network object.
--
-- 'httpStatus', 'createGlobalNetworkResponse_httpStatus' - The response's http status code.
newCreateGlobalNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateGlobalNetworkResponse
newCreateGlobalNetworkResponse :: Int -> CreateGlobalNetworkResponse
newCreateGlobalNetworkResponse Int
pHttpStatus_ =
  CreateGlobalNetworkResponse' :: Maybe GlobalNetwork -> Int -> CreateGlobalNetworkResponse
CreateGlobalNetworkResponse'
    { $sel:globalNetwork:CreateGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork =
        Maybe GlobalNetwork
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateGlobalNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the global network object.
createGlobalNetworkResponse_globalNetwork :: Lens.Lens' CreateGlobalNetworkResponse (Prelude.Maybe GlobalNetwork)
createGlobalNetworkResponse_globalNetwork :: (Maybe GlobalNetwork -> f (Maybe GlobalNetwork))
-> CreateGlobalNetworkResponse -> f CreateGlobalNetworkResponse
createGlobalNetworkResponse_globalNetwork = (CreateGlobalNetworkResponse -> Maybe GlobalNetwork)
-> (CreateGlobalNetworkResponse
    -> Maybe GlobalNetwork -> CreateGlobalNetworkResponse)
-> Lens
     CreateGlobalNetworkResponse
     CreateGlobalNetworkResponse
     (Maybe GlobalNetwork)
     (Maybe GlobalNetwork)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGlobalNetworkResponse' {Maybe GlobalNetwork
globalNetwork :: Maybe GlobalNetwork
$sel:globalNetwork:CreateGlobalNetworkResponse' :: CreateGlobalNetworkResponse -> Maybe GlobalNetwork
globalNetwork} -> Maybe GlobalNetwork
globalNetwork) (\s :: CreateGlobalNetworkResponse
s@CreateGlobalNetworkResponse' {} Maybe GlobalNetwork
a -> CreateGlobalNetworkResponse
s {$sel:globalNetwork:CreateGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork = Maybe GlobalNetwork
a} :: CreateGlobalNetworkResponse)

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

instance Prelude.NFData CreateGlobalNetworkResponse