{-# 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.CloudFront.CreateDistributionWithTags
-- 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 distribution with tags.
module Amazonka.CloudFront.CreateDistributionWithTags
  ( -- * Creating a Request
    CreateDistributionWithTags (..),
    newCreateDistributionWithTags,

    -- * Request Lenses
    createDistributionWithTags_distributionConfigWithTags,

    -- * Destructuring the Response
    CreateDistributionWithTagsResponse (..),
    newCreateDistributionWithTagsResponse,

    -- * Response Lenses
    createDistributionWithTagsResponse_eTag,
    createDistributionWithTagsResponse_distribution,
    createDistributionWithTagsResponse_location,
    createDistributionWithTagsResponse_httpStatus,
  )
where

import Amazonka.CloudFront.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

-- | The request to create a new distribution with tags.
--
-- /See:/ 'newCreateDistributionWithTags' smart constructor.
data CreateDistributionWithTags = CreateDistributionWithTags'
  { -- | The distribution\'s configuration information.
    CreateDistributionWithTags -> DistributionConfigWithTags
distributionConfigWithTags :: DistributionConfigWithTags
  }
  deriving (CreateDistributionWithTags -> CreateDistributionWithTags -> Bool
(CreateDistributionWithTags -> CreateDistributionWithTags -> Bool)
-> (CreateDistributionWithTags
    -> CreateDistributionWithTags -> Bool)
-> Eq CreateDistributionWithTags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDistributionWithTags -> CreateDistributionWithTags -> Bool
$c/= :: CreateDistributionWithTags -> CreateDistributionWithTags -> Bool
== :: CreateDistributionWithTags -> CreateDistributionWithTags -> Bool
$c== :: CreateDistributionWithTags -> CreateDistributionWithTags -> Bool
Prelude.Eq, Int -> CreateDistributionWithTags -> ShowS
[CreateDistributionWithTags] -> ShowS
CreateDistributionWithTags -> String
(Int -> CreateDistributionWithTags -> ShowS)
-> (CreateDistributionWithTags -> String)
-> ([CreateDistributionWithTags] -> ShowS)
-> Show CreateDistributionWithTags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDistributionWithTags] -> ShowS
$cshowList :: [CreateDistributionWithTags] -> ShowS
show :: CreateDistributionWithTags -> String
$cshow :: CreateDistributionWithTags -> String
showsPrec :: Int -> CreateDistributionWithTags -> ShowS
$cshowsPrec :: Int -> CreateDistributionWithTags -> ShowS
Prelude.Show, (forall x.
 CreateDistributionWithTags -> Rep CreateDistributionWithTags x)
-> (forall x.
    Rep CreateDistributionWithTags x -> CreateDistributionWithTags)
-> Generic CreateDistributionWithTags
forall x.
Rep CreateDistributionWithTags x -> CreateDistributionWithTags
forall x.
CreateDistributionWithTags -> Rep CreateDistributionWithTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDistributionWithTags x -> CreateDistributionWithTags
$cfrom :: forall x.
CreateDistributionWithTags -> Rep CreateDistributionWithTags x
Prelude.Generic)

-- |
-- Create a value of 'CreateDistributionWithTags' 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:
--
-- 'distributionConfigWithTags', 'createDistributionWithTags_distributionConfigWithTags' - The distribution\'s configuration information.
newCreateDistributionWithTags ::
  -- | 'distributionConfigWithTags'
  DistributionConfigWithTags ->
  CreateDistributionWithTags
newCreateDistributionWithTags :: DistributionConfigWithTags -> CreateDistributionWithTags
newCreateDistributionWithTags
  DistributionConfigWithTags
pDistributionConfigWithTags_ =
    CreateDistributionWithTags' :: DistributionConfigWithTags -> CreateDistributionWithTags
CreateDistributionWithTags'
      { $sel:distributionConfigWithTags:CreateDistributionWithTags' :: DistributionConfigWithTags
distributionConfigWithTags =
          DistributionConfigWithTags
pDistributionConfigWithTags_
      }

-- | The distribution\'s configuration information.
createDistributionWithTags_distributionConfigWithTags :: Lens.Lens' CreateDistributionWithTags DistributionConfigWithTags
createDistributionWithTags_distributionConfigWithTags :: (DistributionConfigWithTags -> f DistributionConfigWithTags)
-> CreateDistributionWithTags -> f CreateDistributionWithTags
createDistributionWithTags_distributionConfigWithTags = (CreateDistributionWithTags -> DistributionConfigWithTags)
-> (CreateDistributionWithTags
    -> DistributionConfigWithTags -> CreateDistributionWithTags)
-> Lens
     CreateDistributionWithTags
     CreateDistributionWithTags
     DistributionConfigWithTags
     DistributionConfigWithTags
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionWithTags' {DistributionConfigWithTags
distributionConfigWithTags :: DistributionConfigWithTags
$sel:distributionConfigWithTags:CreateDistributionWithTags' :: CreateDistributionWithTags -> DistributionConfigWithTags
distributionConfigWithTags} -> DistributionConfigWithTags
distributionConfigWithTags) (\s :: CreateDistributionWithTags
s@CreateDistributionWithTags' {} DistributionConfigWithTags
a -> CreateDistributionWithTags
s {$sel:distributionConfigWithTags:CreateDistributionWithTags' :: DistributionConfigWithTags
distributionConfigWithTags = DistributionConfigWithTags
a} :: CreateDistributionWithTags)

instance Core.AWSRequest CreateDistributionWithTags where
  type
    AWSResponse CreateDistributionWithTags =
      CreateDistributionWithTagsResponse
  request :: CreateDistributionWithTags -> Request CreateDistributionWithTags
request = Service
-> CreateDistributionWithTags -> Request CreateDistributionWithTags
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDistributionWithTags
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDistributionWithTags)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse CreateDistributionWithTags))
-> Logger
-> Service
-> Proxy CreateDistributionWithTags
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDistributionWithTags)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe Distribution
-> Maybe Text
-> Int
-> CreateDistributionWithTagsResponse
CreateDistributionWithTagsResponse'
            (Maybe Text
 -> Maybe Distribution
 -> Maybe Text
 -> Int
 -> CreateDistributionWithTagsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Distribution
      -> Maybe Text -> Int -> CreateDistributionWithTagsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"ETag")
            Either
  String
  (Maybe Distribution
   -> Maybe Text -> Int -> CreateDistributionWithTagsResponse)
-> Either String (Maybe Distribution)
-> Either
     String (Maybe Text -> Int -> CreateDistributionWithTagsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String (Maybe Distribution)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either
  String (Maybe Text -> Int -> CreateDistributionWithTagsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDistributionWithTagsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Location")
            Either String (Int -> CreateDistributionWithTagsResponse)
-> Either String Int
-> Either String CreateDistributionWithTagsResponse
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 CreateDistributionWithTags

instance Prelude.NFData CreateDistributionWithTags

instance Core.ToElement CreateDistributionWithTags where
  toElement :: CreateDistributionWithTags -> Element
toElement CreateDistributionWithTags' {DistributionConfigWithTags
distributionConfigWithTags :: DistributionConfigWithTags
$sel:distributionConfigWithTags:CreateDistributionWithTags' :: CreateDistributionWithTags -> DistributionConfigWithTags
..} =
    Name -> DistributionConfigWithTags -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
      Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}DistributionConfigWithTags"
      DistributionConfigWithTags
distributionConfigWithTags

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

instance Core.ToPath CreateDistributionWithTags where
  toPath :: CreateDistributionWithTags -> ByteString
toPath = ByteString -> CreateDistributionWithTags -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/distribution"

instance Core.ToQuery CreateDistributionWithTags where
  toQuery :: CreateDistributionWithTags -> QueryString
toQuery =
    QueryString -> CreateDistributionWithTags -> QueryString
forall a b. a -> b -> a
Prelude.const ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"WithTags"])

-- | The returned result of the corresponding request.
--
-- /See:/ 'newCreateDistributionWithTagsResponse' smart constructor.
data CreateDistributionWithTagsResponse = CreateDistributionWithTagsResponse'
  { -- | The current version of the distribution created.
    CreateDistributionWithTagsResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The distribution\'s information.
    CreateDistributionWithTagsResponse -> Maybe Distribution
distribution :: Prelude.Maybe Distribution,
    -- | The fully qualified URI of the new distribution resource just created.
    CreateDistributionWithTagsResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDistributionWithTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDistributionWithTagsResponse
-> CreateDistributionWithTagsResponse -> Bool
(CreateDistributionWithTagsResponse
 -> CreateDistributionWithTagsResponse -> Bool)
-> (CreateDistributionWithTagsResponse
    -> CreateDistributionWithTagsResponse -> Bool)
-> Eq CreateDistributionWithTagsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDistributionWithTagsResponse
-> CreateDistributionWithTagsResponse -> Bool
$c/= :: CreateDistributionWithTagsResponse
-> CreateDistributionWithTagsResponse -> Bool
== :: CreateDistributionWithTagsResponse
-> CreateDistributionWithTagsResponse -> Bool
$c== :: CreateDistributionWithTagsResponse
-> CreateDistributionWithTagsResponse -> Bool
Prelude.Eq, Int -> CreateDistributionWithTagsResponse -> ShowS
[CreateDistributionWithTagsResponse] -> ShowS
CreateDistributionWithTagsResponse -> String
(Int -> CreateDistributionWithTagsResponse -> ShowS)
-> (CreateDistributionWithTagsResponse -> String)
-> ([CreateDistributionWithTagsResponse] -> ShowS)
-> Show CreateDistributionWithTagsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDistributionWithTagsResponse] -> ShowS
$cshowList :: [CreateDistributionWithTagsResponse] -> ShowS
show :: CreateDistributionWithTagsResponse -> String
$cshow :: CreateDistributionWithTagsResponse -> String
showsPrec :: Int -> CreateDistributionWithTagsResponse -> ShowS
$cshowsPrec :: Int -> CreateDistributionWithTagsResponse -> ShowS
Prelude.Show, (forall x.
 CreateDistributionWithTagsResponse
 -> Rep CreateDistributionWithTagsResponse x)
-> (forall x.
    Rep CreateDistributionWithTagsResponse x
    -> CreateDistributionWithTagsResponse)
-> Generic CreateDistributionWithTagsResponse
forall x.
Rep CreateDistributionWithTagsResponse x
-> CreateDistributionWithTagsResponse
forall x.
CreateDistributionWithTagsResponse
-> Rep CreateDistributionWithTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDistributionWithTagsResponse x
-> CreateDistributionWithTagsResponse
$cfrom :: forall x.
CreateDistributionWithTagsResponse
-> Rep CreateDistributionWithTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDistributionWithTagsResponse' 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:
--
-- 'eTag', 'createDistributionWithTagsResponse_eTag' - The current version of the distribution created.
--
-- 'distribution', 'createDistributionWithTagsResponse_distribution' - The distribution\'s information.
--
-- 'location', 'createDistributionWithTagsResponse_location' - The fully qualified URI of the new distribution resource just created.
--
-- 'httpStatus', 'createDistributionWithTagsResponse_httpStatus' - The response's http status code.
newCreateDistributionWithTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDistributionWithTagsResponse
newCreateDistributionWithTagsResponse :: Int -> CreateDistributionWithTagsResponse
newCreateDistributionWithTagsResponse Int
pHttpStatus_ =
  CreateDistributionWithTagsResponse' :: Maybe Text
-> Maybe Distribution
-> Maybe Text
-> Int
-> CreateDistributionWithTagsResponse
CreateDistributionWithTagsResponse'
    { $sel:eTag:CreateDistributionWithTagsResponse' :: Maybe Text
eTag =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:distribution:CreateDistributionWithTagsResponse' :: Maybe Distribution
distribution = Maybe Distribution
forall a. Maybe a
Prelude.Nothing,
      $sel:location:CreateDistributionWithTagsResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDistributionWithTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current version of the distribution created.
createDistributionWithTagsResponse_eTag :: Lens.Lens' CreateDistributionWithTagsResponse (Prelude.Maybe Prelude.Text)
createDistributionWithTagsResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> CreateDistributionWithTagsResponse
-> f CreateDistributionWithTagsResponse
createDistributionWithTagsResponse_eTag = (CreateDistributionWithTagsResponse -> Maybe Text)
-> (CreateDistributionWithTagsResponse
    -> Maybe Text -> CreateDistributionWithTagsResponse)
-> Lens
     CreateDistributionWithTagsResponse
     CreateDistributionWithTagsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionWithTagsResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:CreateDistributionWithTagsResponse' :: CreateDistributionWithTagsResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: CreateDistributionWithTagsResponse
s@CreateDistributionWithTagsResponse' {} Maybe Text
a -> CreateDistributionWithTagsResponse
s {$sel:eTag:CreateDistributionWithTagsResponse' :: Maybe Text
eTag = Maybe Text
a} :: CreateDistributionWithTagsResponse)

-- | The distribution\'s information.
createDistributionWithTagsResponse_distribution :: Lens.Lens' CreateDistributionWithTagsResponse (Prelude.Maybe Distribution)
createDistributionWithTagsResponse_distribution :: (Maybe Distribution -> f (Maybe Distribution))
-> CreateDistributionWithTagsResponse
-> f CreateDistributionWithTagsResponse
createDistributionWithTagsResponse_distribution = (CreateDistributionWithTagsResponse -> Maybe Distribution)
-> (CreateDistributionWithTagsResponse
    -> Maybe Distribution -> CreateDistributionWithTagsResponse)
-> Lens
     CreateDistributionWithTagsResponse
     CreateDistributionWithTagsResponse
     (Maybe Distribution)
     (Maybe Distribution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionWithTagsResponse' {Maybe Distribution
distribution :: Maybe Distribution
$sel:distribution:CreateDistributionWithTagsResponse' :: CreateDistributionWithTagsResponse -> Maybe Distribution
distribution} -> Maybe Distribution
distribution) (\s :: CreateDistributionWithTagsResponse
s@CreateDistributionWithTagsResponse' {} Maybe Distribution
a -> CreateDistributionWithTagsResponse
s {$sel:distribution:CreateDistributionWithTagsResponse' :: Maybe Distribution
distribution = Maybe Distribution
a} :: CreateDistributionWithTagsResponse)

-- | The fully qualified URI of the new distribution resource just created.
createDistributionWithTagsResponse_location :: Lens.Lens' CreateDistributionWithTagsResponse (Prelude.Maybe Prelude.Text)
createDistributionWithTagsResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateDistributionWithTagsResponse
-> f CreateDistributionWithTagsResponse
createDistributionWithTagsResponse_location = (CreateDistributionWithTagsResponse -> Maybe Text)
-> (CreateDistributionWithTagsResponse
    -> Maybe Text -> CreateDistributionWithTagsResponse)
-> Lens
     CreateDistributionWithTagsResponse
     CreateDistributionWithTagsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionWithTagsResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateDistributionWithTagsResponse' :: CreateDistributionWithTagsResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateDistributionWithTagsResponse
s@CreateDistributionWithTagsResponse' {} Maybe Text
a -> CreateDistributionWithTagsResponse
s {$sel:location:CreateDistributionWithTagsResponse' :: Maybe Text
location = Maybe Text
a} :: CreateDistributionWithTagsResponse)

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

instance
  Prelude.NFData
    CreateDistributionWithTagsResponse