{-# 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.AppSync.FlushApiCache
-- 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)
--
-- Flushes an @ApiCache@ object.
module Amazonka.AppSync.FlushApiCache
  ( -- * Creating a Request
    FlushApiCache (..),
    newFlushApiCache,

    -- * Request Lenses
    flushApiCache_apiId,

    -- * Destructuring the Response
    FlushApiCacheResponse (..),
    newFlushApiCacheResponse,

    -- * Response Lenses
    flushApiCacheResponse_httpStatus,
  )
where

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

-- | Represents the input of a @FlushApiCache@ operation.
--
-- /See:/ 'newFlushApiCache' smart constructor.
data FlushApiCache = FlushApiCache'
  { -- | The API ID.
    FlushApiCache -> Text
apiId :: Prelude.Text
  }
  deriving (FlushApiCache -> FlushApiCache -> Bool
(FlushApiCache -> FlushApiCache -> Bool)
-> (FlushApiCache -> FlushApiCache -> Bool) -> Eq FlushApiCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FlushApiCache -> FlushApiCache -> Bool
$c/= :: FlushApiCache -> FlushApiCache -> Bool
== :: FlushApiCache -> FlushApiCache -> Bool
$c== :: FlushApiCache -> FlushApiCache -> Bool
Prelude.Eq, ReadPrec [FlushApiCache]
ReadPrec FlushApiCache
Int -> ReadS FlushApiCache
ReadS [FlushApiCache]
(Int -> ReadS FlushApiCache)
-> ReadS [FlushApiCache]
-> ReadPrec FlushApiCache
-> ReadPrec [FlushApiCache]
-> Read FlushApiCache
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FlushApiCache]
$creadListPrec :: ReadPrec [FlushApiCache]
readPrec :: ReadPrec FlushApiCache
$creadPrec :: ReadPrec FlushApiCache
readList :: ReadS [FlushApiCache]
$creadList :: ReadS [FlushApiCache]
readsPrec :: Int -> ReadS FlushApiCache
$creadsPrec :: Int -> ReadS FlushApiCache
Prelude.Read, Int -> FlushApiCache -> ShowS
[FlushApiCache] -> ShowS
FlushApiCache -> String
(Int -> FlushApiCache -> ShowS)
-> (FlushApiCache -> String)
-> ([FlushApiCache] -> ShowS)
-> Show FlushApiCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlushApiCache] -> ShowS
$cshowList :: [FlushApiCache] -> ShowS
show :: FlushApiCache -> String
$cshow :: FlushApiCache -> String
showsPrec :: Int -> FlushApiCache -> ShowS
$cshowsPrec :: Int -> FlushApiCache -> ShowS
Prelude.Show, (forall x. FlushApiCache -> Rep FlushApiCache x)
-> (forall x. Rep FlushApiCache x -> FlushApiCache)
-> Generic FlushApiCache
forall x. Rep FlushApiCache x -> FlushApiCache
forall x. FlushApiCache -> Rep FlushApiCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FlushApiCache x -> FlushApiCache
$cfrom :: forall x. FlushApiCache -> Rep FlushApiCache x
Prelude.Generic)

-- |
-- Create a value of 'FlushApiCache' 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:
--
-- 'apiId', 'flushApiCache_apiId' - The API ID.
newFlushApiCache ::
  -- | 'apiId'
  Prelude.Text ->
  FlushApiCache
newFlushApiCache :: Text -> FlushApiCache
newFlushApiCache Text
pApiId_ =
  FlushApiCache' :: Text -> FlushApiCache
FlushApiCache' {$sel:apiId:FlushApiCache' :: Text
apiId = Text
pApiId_}

-- | The API ID.
flushApiCache_apiId :: Lens.Lens' FlushApiCache Prelude.Text
flushApiCache_apiId :: (Text -> f Text) -> FlushApiCache -> f FlushApiCache
flushApiCache_apiId = (FlushApiCache -> Text)
-> (FlushApiCache -> Text -> FlushApiCache)
-> Lens FlushApiCache FlushApiCache Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlushApiCache' {Text
apiId :: Text
$sel:apiId:FlushApiCache' :: FlushApiCache -> Text
apiId} -> Text
apiId) (\s :: FlushApiCache
s@FlushApiCache' {} Text
a -> FlushApiCache
s {$sel:apiId:FlushApiCache' :: Text
apiId = Text
a} :: FlushApiCache)

instance Core.AWSRequest FlushApiCache where
  type
    AWSResponse FlushApiCache =
      FlushApiCacheResponse
  request :: FlushApiCache -> Request FlushApiCache
request = Service -> FlushApiCache -> Request FlushApiCache
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy FlushApiCache
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse FlushApiCache)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse FlushApiCache))
-> Logger
-> Service
-> Proxy FlushApiCache
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse FlushApiCache)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> FlushApiCacheResponse
FlushApiCacheResponse'
            (Int -> FlushApiCacheResponse)
-> Either String Int -> Either String FlushApiCacheResponse
forall (f :: * -> *) a b. Functor 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 FlushApiCache

instance Prelude.NFData FlushApiCache

instance Core.ToHeaders FlushApiCache where
  toHeaders :: FlushApiCache -> ResponseHeaders
toHeaders =
    ResponseHeaders -> FlushApiCache -> 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.ToPath FlushApiCache where
  toPath :: FlushApiCache -> ByteString
toPath FlushApiCache' {Text
apiId :: Text
$sel:apiId:FlushApiCache' :: FlushApiCache -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/apis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId, ByteString
"/FlushCache"]

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

-- | Represents the output of a @FlushApiCache@ operation.
--
-- /See:/ 'newFlushApiCacheResponse' smart constructor.
data FlushApiCacheResponse = FlushApiCacheResponse'
  { -- | The response's http status code.
    FlushApiCacheResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (FlushApiCacheResponse -> FlushApiCacheResponse -> Bool
(FlushApiCacheResponse -> FlushApiCacheResponse -> Bool)
-> (FlushApiCacheResponse -> FlushApiCacheResponse -> Bool)
-> Eq FlushApiCacheResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FlushApiCacheResponse -> FlushApiCacheResponse -> Bool
$c/= :: FlushApiCacheResponse -> FlushApiCacheResponse -> Bool
== :: FlushApiCacheResponse -> FlushApiCacheResponse -> Bool
$c== :: FlushApiCacheResponse -> FlushApiCacheResponse -> Bool
Prelude.Eq, ReadPrec [FlushApiCacheResponse]
ReadPrec FlushApiCacheResponse
Int -> ReadS FlushApiCacheResponse
ReadS [FlushApiCacheResponse]
(Int -> ReadS FlushApiCacheResponse)
-> ReadS [FlushApiCacheResponse]
-> ReadPrec FlushApiCacheResponse
-> ReadPrec [FlushApiCacheResponse]
-> Read FlushApiCacheResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FlushApiCacheResponse]
$creadListPrec :: ReadPrec [FlushApiCacheResponse]
readPrec :: ReadPrec FlushApiCacheResponse
$creadPrec :: ReadPrec FlushApiCacheResponse
readList :: ReadS [FlushApiCacheResponse]
$creadList :: ReadS [FlushApiCacheResponse]
readsPrec :: Int -> ReadS FlushApiCacheResponse
$creadsPrec :: Int -> ReadS FlushApiCacheResponse
Prelude.Read, Int -> FlushApiCacheResponse -> ShowS
[FlushApiCacheResponse] -> ShowS
FlushApiCacheResponse -> String
(Int -> FlushApiCacheResponse -> ShowS)
-> (FlushApiCacheResponse -> String)
-> ([FlushApiCacheResponse] -> ShowS)
-> Show FlushApiCacheResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlushApiCacheResponse] -> ShowS
$cshowList :: [FlushApiCacheResponse] -> ShowS
show :: FlushApiCacheResponse -> String
$cshow :: FlushApiCacheResponse -> String
showsPrec :: Int -> FlushApiCacheResponse -> ShowS
$cshowsPrec :: Int -> FlushApiCacheResponse -> ShowS
Prelude.Show, (forall x. FlushApiCacheResponse -> Rep FlushApiCacheResponse x)
-> (forall x. Rep FlushApiCacheResponse x -> FlushApiCacheResponse)
-> Generic FlushApiCacheResponse
forall x. Rep FlushApiCacheResponse x -> FlushApiCacheResponse
forall x. FlushApiCacheResponse -> Rep FlushApiCacheResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FlushApiCacheResponse x -> FlushApiCacheResponse
$cfrom :: forall x. FlushApiCacheResponse -> Rep FlushApiCacheResponse x
Prelude.Generic)

-- |
-- Create a value of 'FlushApiCacheResponse' 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:
--
-- 'httpStatus', 'flushApiCacheResponse_httpStatus' - The response's http status code.
newFlushApiCacheResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  FlushApiCacheResponse
newFlushApiCacheResponse :: Int -> FlushApiCacheResponse
newFlushApiCacheResponse Int
pHttpStatus_ =
  FlushApiCacheResponse' :: Int -> FlushApiCacheResponse
FlushApiCacheResponse' {$sel:httpStatus:FlushApiCacheResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData FlushApiCacheResponse