{-# 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.Lightsail.UpdateDistribution
-- 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)
--
-- Updates an existing Amazon Lightsail content delivery network (CDN)
-- distribution.
--
-- Use this action to update the configuration of your existing
-- distribution.
module Amazonka.Lightsail.UpdateDistribution
  ( -- * Creating a Request
    UpdateDistribution (..),
    newUpdateDistribution,

    -- * Request Lenses
    updateDistribution_origin,
    updateDistribution_cacheBehaviorSettings,
    updateDistribution_isEnabled,
    updateDistribution_defaultCacheBehavior,
    updateDistribution_cacheBehaviors,
    updateDistribution_distributionName,

    -- * Destructuring the Response
    UpdateDistributionResponse (..),
    newUpdateDistributionResponse,

    -- * Response Lenses
    updateDistributionResponse_operation,
    updateDistributionResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateDistribution' smart constructor.
data UpdateDistribution = UpdateDistribution'
  { -- | An object that describes the origin resource for the distribution, such
    -- as a Lightsail instance or load balancer.
    --
    -- The distribution pulls, caches, and serves content from the origin.
    UpdateDistribution -> Maybe InputOrigin
origin :: Prelude.Maybe InputOrigin,
    -- | An object that describes the cache behavior settings for the
    -- distribution.
    --
    -- The @cacheBehaviorSettings@ specified in your
    -- @UpdateDistributionRequest@ will replace your distribution\'s existing
    -- settings.
    UpdateDistribution -> Maybe CacheSettings
cacheBehaviorSettings :: Prelude.Maybe CacheSettings,
    -- | Indicates whether to enable the distribution.
    UpdateDistribution -> Maybe Bool
isEnabled :: Prelude.Maybe Prelude.Bool,
    -- | An object that describes the default cache behavior for the
    -- distribution.
    UpdateDistribution -> Maybe CacheBehavior
defaultCacheBehavior :: Prelude.Maybe CacheBehavior,
    -- | An array of objects that describe the per-path cache behavior for the
    -- distribution.
    UpdateDistribution -> Maybe [CacheBehaviorPerPath]
cacheBehaviors :: Prelude.Maybe [CacheBehaviorPerPath],
    -- | The name of the distribution to update.
    --
    -- Use the @GetDistributions@ action to get a list of distribution names
    -- that you can specify.
    UpdateDistribution -> Text
distributionName :: Prelude.Text
  }
  deriving (UpdateDistribution -> UpdateDistribution -> Bool
(UpdateDistribution -> UpdateDistribution -> Bool)
-> (UpdateDistribution -> UpdateDistribution -> Bool)
-> Eq UpdateDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDistribution -> UpdateDistribution -> Bool
$c/= :: UpdateDistribution -> UpdateDistribution -> Bool
== :: UpdateDistribution -> UpdateDistribution -> Bool
$c== :: UpdateDistribution -> UpdateDistribution -> Bool
Prelude.Eq, ReadPrec [UpdateDistribution]
ReadPrec UpdateDistribution
Int -> ReadS UpdateDistribution
ReadS [UpdateDistribution]
(Int -> ReadS UpdateDistribution)
-> ReadS [UpdateDistribution]
-> ReadPrec UpdateDistribution
-> ReadPrec [UpdateDistribution]
-> Read UpdateDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDistribution]
$creadListPrec :: ReadPrec [UpdateDistribution]
readPrec :: ReadPrec UpdateDistribution
$creadPrec :: ReadPrec UpdateDistribution
readList :: ReadS [UpdateDistribution]
$creadList :: ReadS [UpdateDistribution]
readsPrec :: Int -> ReadS UpdateDistribution
$creadsPrec :: Int -> ReadS UpdateDistribution
Prelude.Read, Int -> UpdateDistribution -> ShowS
[UpdateDistribution] -> ShowS
UpdateDistribution -> String
(Int -> UpdateDistribution -> ShowS)
-> (UpdateDistribution -> String)
-> ([UpdateDistribution] -> ShowS)
-> Show UpdateDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDistribution] -> ShowS
$cshowList :: [UpdateDistribution] -> ShowS
show :: UpdateDistribution -> String
$cshow :: UpdateDistribution -> String
showsPrec :: Int -> UpdateDistribution -> ShowS
$cshowsPrec :: Int -> UpdateDistribution -> ShowS
Prelude.Show, (forall x. UpdateDistribution -> Rep UpdateDistribution x)
-> (forall x. Rep UpdateDistribution x -> UpdateDistribution)
-> Generic UpdateDistribution
forall x. Rep UpdateDistribution x -> UpdateDistribution
forall x. UpdateDistribution -> Rep UpdateDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDistribution x -> UpdateDistribution
$cfrom :: forall x. UpdateDistribution -> Rep UpdateDistribution x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDistribution' 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:
--
-- 'origin', 'updateDistribution_origin' - An object that describes the origin resource for the distribution, such
-- as a Lightsail instance or load balancer.
--
-- The distribution pulls, caches, and serves content from the origin.
--
-- 'cacheBehaviorSettings', 'updateDistribution_cacheBehaviorSettings' - An object that describes the cache behavior settings for the
-- distribution.
--
-- The @cacheBehaviorSettings@ specified in your
-- @UpdateDistributionRequest@ will replace your distribution\'s existing
-- settings.
--
-- 'isEnabled', 'updateDistribution_isEnabled' - Indicates whether to enable the distribution.
--
-- 'defaultCacheBehavior', 'updateDistribution_defaultCacheBehavior' - An object that describes the default cache behavior for the
-- distribution.
--
-- 'cacheBehaviors', 'updateDistribution_cacheBehaviors' - An array of objects that describe the per-path cache behavior for the
-- distribution.
--
-- 'distributionName', 'updateDistribution_distributionName' - The name of the distribution to update.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
newUpdateDistribution ::
  -- | 'distributionName'
  Prelude.Text ->
  UpdateDistribution
newUpdateDistribution :: Text -> UpdateDistribution
newUpdateDistribution Text
pDistributionName_ =
  UpdateDistribution' :: Maybe InputOrigin
-> Maybe CacheSettings
-> Maybe Bool
-> Maybe CacheBehavior
-> Maybe [CacheBehaviorPerPath]
-> Text
-> UpdateDistribution
UpdateDistribution'
    { $sel:origin:UpdateDistribution' :: Maybe InputOrigin
origin = Maybe InputOrigin
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheBehaviorSettings:UpdateDistribution' :: Maybe CacheSettings
cacheBehaviorSettings = Maybe CacheSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:isEnabled:UpdateDistribution' :: Maybe Bool
isEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultCacheBehavior:UpdateDistribution' :: Maybe CacheBehavior
defaultCacheBehavior = Maybe CacheBehavior
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheBehaviors:UpdateDistribution' :: Maybe [CacheBehaviorPerPath]
cacheBehaviors = Maybe [CacheBehaviorPerPath]
forall a. Maybe a
Prelude.Nothing,
      $sel:distributionName:UpdateDistribution' :: Text
distributionName = Text
pDistributionName_
    }

-- | An object that describes the origin resource for the distribution, such
-- as a Lightsail instance or load balancer.
--
-- The distribution pulls, caches, and serves content from the origin.
updateDistribution_origin :: Lens.Lens' UpdateDistribution (Prelude.Maybe InputOrigin)
updateDistribution_origin :: (Maybe InputOrigin -> f (Maybe InputOrigin))
-> UpdateDistribution -> f UpdateDistribution
updateDistribution_origin = (UpdateDistribution -> Maybe InputOrigin)
-> (UpdateDistribution -> Maybe InputOrigin -> UpdateDistribution)
-> Lens
     UpdateDistribution
     UpdateDistribution
     (Maybe InputOrigin)
     (Maybe InputOrigin)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Maybe InputOrigin
origin :: Maybe InputOrigin
$sel:origin:UpdateDistribution' :: UpdateDistribution -> Maybe InputOrigin
origin} -> Maybe InputOrigin
origin) (\s :: UpdateDistribution
s@UpdateDistribution' {} Maybe InputOrigin
a -> UpdateDistribution
s {$sel:origin:UpdateDistribution' :: Maybe InputOrigin
origin = Maybe InputOrigin
a} :: UpdateDistribution)

-- | An object that describes the cache behavior settings for the
-- distribution.
--
-- The @cacheBehaviorSettings@ specified in your
-- @UpdateDistributionRequest@ will replace your distribution\'s existing
-- settings.
updateDistribution_cacheBehaviorSettings :: Lens.Lens' UpdateDistribution (Prelude.Maybe CacheSettings)
updateDistribution_cacheBehaviorSettings :: (Maybe CacheSettings -> f (Maybe CacheSettings))
-> UpdateDistribution -> f UpdateDistribution
updateDistribution_cacheBehaviorSettings = (UpdateDistribution -> Maybe CacheSettings)
-> (UpdateDistribution
    -> Maybe CacheSettings -> UpdateDistribution)
-> Lens
     UpdateDistribution
     UpdateDistribution
     (Maybe CacheSettings)
     (Maybe CacheSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Maybe CacheSettings
cacheBehaviorSettings :: Maybe CacheSettings
$sel:cacheBehaviorSettings:UpdateDistribution' :: UpdateDistribution -> Maybe CacheSettings
cacheBehaviorSettings} -> Maybe CacheSettings
cacheBehaviorSettings) (\s :: UpdateDistribution
s@UpdateDistribution' {} Maybe CacheSettings
a -> UpdateDistribution
s {$sel:cacheBehaviorSettings:UpdateDistribution' :: Maybe CacheSettings
cacheBehaviorSettings = Maybe CacheSettings
a} :: UpdateDistribution)

-- | Indicates whether to enable the distribution.
updateDistribution_isEnabled :: Lens.Lens' UpdateDistribution (Prelude.Maybe Prelude.Bool)
updateDistribution_isEnabled :: (Maybe Bool -> f (Maybe Bool))
-> UpdateDistribution -> f UpdateDistribution
updateDistribution_isEnabled = (UpdateDistribution -> Maybe Bool)
-> (UpdateDistribution -> Maybe Bool -> UpdateDistribution)
-> Lens
     UpdateDistribution UpdateDistribution (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Maybe Bool
isEnabled :: Maybe Bool
$sel:isEnabled:UpdateDistribution' :: UpdateDistribution -> Maybe Bool
isEnabled} -> Maybe Bool
isEnabled) (\s :: UpdateDistribution
s@UpdateDistribution' {} Maybe Bool
a -> UpdateDistribution
s {$sel:isEnabled:UpdateDistribution' :: Maybe Bool
isEnabled = Maybe Bool
a} :: UpdateDistribution)

-- | An object that describes the default cache behavior for the
-- distribution.
updateDistribution_defaultCacheBehavior :: Lens.Lens' UpdateDistribution (Prelude.Maybe CacheBehavior)
updateDistribution_defaultCacheBehavior :: (Maybe CacheBehavior -> f (Maybe CacheBehavior))
-> UpdateDistribution -> f UpdateDistribution
updateDistribution_defaultCacheBehavior = (UpdateDistribution -> Maybe CacheBehavior)
-> (UpdateDistribution
    -> Maybe CacheBehavior -> UpdateDistribution)
-> Lens
     UpdateDistribution
     UpdateDistribution
     (Maybe CacheBehavior)
     (Maybe CacheBehavior)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Maybe CacheBehavior
defaultCacheBehavior :: Maybe CacheBehavior
$sel:defaultCacheBehavior:UpdateDistribution' :: UpdateDistribution -> Maybe CacheBehavior
defaultCacheBehavior} -> Maybe CacheBehavior
defaultCacheBehavior) (\s :: UpdateDistribution
s@UpdateDistribution' {} Maybe CacheBehavior
a -> UpdateDistribution
s {$sel:defaultCacheBehavior:UpdateDistribution' :: Maybe CacheBehavior
defaultCacheBehavior = Maybe CacheBehavior
a} :: UpdateDistribution)

-- | An array of objects that describe the per-path cache behavior for the
-- distribution.
updateDistribution_cacheBehaviors :: Lens.Lens' UpdateDistribution (Prelude.Maybe [CacheBehaviorPerPath])
updateDistribution_cacheBehaviors :: (Maybe [CacheBehaviorPerPath] -> f (Maybe [CacheBehaviorPerPath]))
-> UpdateDistribution -> f UpdateDistribution
updateDistribution_cacheBehaviors = (UpdateDistribution -> Maybe [CacheBehaviorPerPath])
-> (UpdateDistribution
    -> Maybe [CacheBehaviorPerPath] -> UpdateDistribution)
-> Lens
     UpdateDistribution
     UpdateDistribution
     (Maybe [CacheBehaviorPerPath])
     (Maybe [CacheBehaviorPerPath])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Maybe [CacheBehaviorPerPath]
cacheBehaviors :: Maybe [CacheBehaviorPerPath]
$sel:cacheBehaviors:UpdateDistribution' :: UpdateDistribution -> Maybe [CacheBehaviorPerPath]
cacheBehaviors} -> Maybe [CacheBehaviorPerPath]
cacheBehaviors) (\s :: UpdateDistribution
s@UpdateDistribution' {} Maybe [CacheBehaviorPerPath]
a -> UpdateDistribution
s {$sel:cacheBehaviors:UpdateDistribution' :: Maybe [CacheBehaviorPerPath]
cacheBehaviors = Maybe [CacheBehaviorPerPath]
a} :: UpdateDistribution) ((Maybe [CacheBehaviorPerPath] -> f (Maybe [CacheBehaviorPerPath]))
 -> UpdateDistribution -> f UpdateDistribution)
-> ((Maybe [CacheBehaviorPerPath]
     -> f (Maybe [CacheBehaviorPerPath]))
    -> Maybe [CacheBehaviorPerPath]
    -> f (Maybe [CacheBehaviorPerPath]))
-> (Maybe [CacheBehaviorPerPath]
    -> f (Maybe [CacheBehaviorPerPath]))
-> UpdateDistribution
-> f UpdateDistribution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
-> Iso
     (Maybe [CacheBehaviorPerPath])
     (Maybe [CacheBehaviorPerPath])
     (Maybe [CacheBehaviorPerPath])
     (Maybe [CacheBehaviorPerPath])
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
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
  [CacheBehaviorPerPath]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the distribution to update.
--
-- Use the @GetDistributions@ action to get a list of distribution names
-- that you can specify.
updateDistribution_distributionName :: Lens.Lens' UpdateDistribution Prelude.Text
updateDistribution_distributionName :: (Text -> f Text) -> UpdateDistribution -> f UpdateDistribution
updateDistribution_distributionName = (UpdateDistribution -> Text)
-> (UpdateDistribution -> Text -> UpdateDistribution)
-> Lens UpdateDistribution UpdateDistribution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistribution' {Text
distributionName :: Text
$sel:distributionName:UpdateDistribution' :: UpdateDistribution -> Text
distributionName} -> Text
distributionName) (\s :: UpdateDistribution
s@UpdateDistribution' {} Text
a -> UpdateDistribution
s {$sel:distributionName:UpdateDistribution' :: Text
distributionName = Text
a} :: UpdateDistribution)

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

instance Prelude.NFData UpdateDistribution

instance Core.ToHeaders UpdateDistribution where
  toHeaders :: UpdateDistribution -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDistribution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.UpdateDistribution" ::
                          Prelude.ByteString
                      ),
            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 UpdateDistribution where
  toJSON :: UpdateDistribution -> Value
toJSON UpdateDistribution' {Maybe Bool
Maybe [CacheBehaviorPerPath]
Maybe CacheBehavior
Maybe CacheSettings
Maybe InputOrigin
Text
distributionName :: Text
cacheBehaviors :: Maybe [CacheBehaviorPerPath]
defaultCacheBehavior :: Maybe CacheBehavior
isEnabled :: Maybe Bool
cacheBehaviorSettings :: Maybe CacheSettings
origin :: Maybe InputOrigin
$sel:distributionName:UpdateDistribution' :: UpdateDistribution -> Text
$sel:cacheBehaviors:UpdateDistribution' :: UpdateDistribution -> Maybe [CacheBehaviorPerPath]
$sel:defaultCacheBehavior:UpdateDistribution' :: UpdateDistribution -> Maybe CacheBehavior
$sel:isEnabled:UpdateDistribution' :: UpdateDistribution -> Maybe Bool
$sel:cacheBehaviorSettings:UpdateDistribution' :: UpdateDistribution -> Maybe CacheSettings
$sel:origin:UpdateDistribution' :: UpdateDistribution -> Maybe InputOrigin
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"origin" Text -> InputOrigin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (InputOrigin -> Pair) -> Maybe InputOrigin -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputOrigin
origin,
            (Text
"cacheBehaviorSettings" Text -> CacheSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CacheSettings -> Pair) -> Maybe CacheSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CacheSettings
cacheBehaviorSettings,
            (Text
"isEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isEnabled,
            (Text
"defaultCacheBehavior" Text -> CacheBehavior -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CacheBehavior -> Pair) -> Maybe CacheBehavior -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CacheBehavior
defaultCacheBehavior,
            (Text
"cacheBehaviors" Text -> [CacheBehaviorPerPath] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CacheBehaviorPerPath] -> Pair)
-> Maybe [CacheBehaviorPerPath] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CacheBehaviorPerPath]
cacheBehaviors,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"distributionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
distributionName)
          ]
      )

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

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

-- | /See:/ 'newUpdateDistributionResponse' smart constructor.
data UpdateDistributionResponse = UpdateDistributionResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    UpdateDistributionResponse -> Maybe Operation
operation :: Prelude.Maybe Operation,
    -- | The response's http status code.
    UpdateDistributionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateDistributionResponse -> UpdateDistributionResponse -> Bool
(UpdateDistributionResponse -> UpdateDistributionResponse -> Bool)
-> (UpdateDistributionResponse
    -> UpdateDistributionResponse -> Bool)
-> Eq UpdateDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDistributionResponse -> UpdateDistributionResponse -> Bool
$c/= :: UpdateDistributionResponse -> UpdateDistributionResponse -> Bool
== :: UpdateDistributionResponse -> UpdateDistributionResponse -> Bool
$c== :: UpdateDistributionResponse -> UpdateDistributionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDistributionResponse]
ReadPrec UpdateDistributionResponse
Int -> ReadS UpdateDistributionResponse
ReadS [UpdateDistributionResponse]
(Int -> ReadS UpdateDistributionResponse)
-> ReadS [UpdateDistributionResponse]
-> ReadPrec UpdateDistributionResponse
-> ReadPrec [UpdateDistributionResponse]
-> Read UpdateDistributionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDistributionResponse]
$creadListPrec :: ReadPrec [UpdateDistributionResponse]
readPrec :: ReadPrec UpdateDistributionResponse
$creadPrec :: ReadPrec UpdateDistributionResponse
readList :: ReadS [UpdateDistributionResponse]
$creadList :: ReadS [UpdateDistributionResponse]
readsPrec :: Int -> ReadS UpdateDistributionResponse
$creadsPrec :: Int -> ReadS UpdateDistributionResponse
Prelude.Read, Int -> UpdateDistributionResponse -> ShowS
[UpdateDistributionResponse] -> ShowS
UpdateDistributionResponse -> String
(Int -> UpdateDistributionResponse -> ShowS)
-> (UpdateDistributionResponse -> String)
-> ([UpdateDistributionResponse] -> ShowS)
-> Show UpdateDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDistributionResponse] -> ShowS
$cshowList :: [UpdateDistributionResponse] -> ShowS
show :: UpdateDistributionResponse -> String
$cshow :: UpdateDistributionResponse -> String
showsPrec :: Int -> UpdateDistributionResponse -> ShowS
$cshowsPrec :: Int -> UpdateDistributionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateDistributionResponse -> Rep UpdateDistributionResponse x)
-> (forall x.
    Rep UpdateDistributionResponse x -> UpdateDistributionResponse)
-> Generic UpdateDistributionResponse
forall x.
Rep UpdateDistributionResponse x -> UpdateDistributionResponse
forall x.
UpdateDistributionResponse -> Rep UpdateDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDistributionResponse x -> UpdateDistributionResponse
$cfrom :: forall x.
UpdateDistributionResponse -> Rep UpdateDistributionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDistributionResponse' 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:
--
-- 'operation', 'updateDistributionResponse_operation' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'updateDistributionResponse_httpStatus' - The response's http status code.
newUpdateDistributionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDistributionResponse
newUpdateDistributionResponse :: Int -> UpdateDistributionResponse
newUpdateDistributionResponse Int
pHttpStatus_ =
  UpdateDistributionResponse' :: Maybe Operation -> Int -> UpdateDistributionResponse
UpdateDistributionResponse'
    { $sel:operation:UpdateDistributionResponse' :: Maybe Operation
operation =
        Maybe Operation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
updateDistributionResponse_operation :: Lens.Lens' UpdateDistributionResponse (Prelude.Maybe Operation)
updateDistributionResponse_operation :: (Maybe Operation -> f (Maybe Operation))
-> UpdateDistributionResponse -> f UpdateDistributionResponse
updateDistributionResponse_operation = (UpdateDistributionResponse -> Maybe Operation)
-> (UpdateDistributionResponse
    -> Maybe Operation -> UpdateDistributionResponse)
-> Lens
     UpdateDistributionResponse
     UpdateDistributionResponse
     (Maybe Operation)
     (Maybe Operation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDistributionResponse' {Maybe Operation
operation :: Maybe Operation
$sel:operation:UpdateDistributionResponse' :: UpdateDistributionResponse -> Maybe Operation
operation} -> Maybe Operation
operation) (\s :: UpdateDistributionResponse
s@UpdateDistributionResponse' {} Maybe Operation
a -> UpdateDistributionResponse
s {$sel:operation:UpdateDistributionResponse' :: Maybe Operation
operation = Maybe Operation
a} :: UpdateDistributionResponse)

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

instance Prelude.NFData UpdateDistributionResponse