{-# 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.MediaStore.DeleteCorsPolicy
-- 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)
--
-- Deletes the cross-origin resource sharing (CORS) configuration
-- information that is set for the container.
--
-- To use this operation, you must have permission to perform the
-- @MediaStore:DeleteCorsPolicy@ action. The container owner has this
-- permission by default and can grant this permission to others.
module Amazonka.MediaStore.DeleteCorsPolicy
  ( -- * Creating a Request
    DeleteCorsPolicy (..),
    newDeleteCorsPolicy,

    -- * Request Lenses
    deleteCorsPolicy_containerName,

    -- * Destructuring the Response
    DeleteCorsPolicyResponse (..),
    newDeleteCorsPolicyResponse,

    -- * Response Lenses
    deleteCorsPolicyResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteCorsPolicy' smart constructor.
data DeleteCorsPolicy = DeleteCorsPolicy'
  { -- | The name of the container to remove the policy from.
    DeleteCorsPolicy -> Text
containerName :: Prelude.Text
  }
  deriving (DeleteCorsPolicy -> DeleteCorsPolicy -> Bool
(DeleteCorsPolicy -> DeleteCorsPolicy -> Bool)
-> (DeleteCorsPolicy -> DeleteCorsPolicy -> Bool)
-> Eq DeleteCorsPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCorsPolicy -> DeleteCorsPolicy -> Bool
$c/= :: DeleteCorsPolicy -> DeleteCorsPolicy -> Bool
== :: DeleteCorsPolicy -> DeleteCorsPolicy -> Bool
$c== :: DeleteCorsPolicy -> DeleteCorsPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteCorsPolicy]
ReadPrec DeleteCorsPolicy
Int -> ReadS DeleteCorsPolicy
ReadS [DeleteCorsPolicy]
(Int -> ReadS DeleteCorsPolicy)
-> ReadS [DeleteCorsPolicy]
-> ReadPrec DeleteCorsPolicy
-> ReadPrec [DeleteCorsPolicy]
-> Read DeleteCorsPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCorsPolicy]
$creadListPrec :: ReadPrec [DeleteCorsPolicy]
readPrec :: ReadPrec DeleteCorsPolicy
$creadPrec :: ReadPrec DeleteCorsPolicy
readList :: ReadS [DeleteCorsPolicy]
$creadList :: ReadS [DeleteCorsPolicy]
readsPrec :: Int -> ReadS DeleteCorsPolicy
$creadsPrec :: Int -> ReadS DeleteCorsPolicy
Prelude.Read, Int -> DeleteCorsPolicy -> ShowS
[DeleteCorsPolicy] -> ShowS
DeleteCorsPolicy -> String
(Int -> DeleteCorsPolicy -> ShowS)
-> (DeleteCorsPolicy -> String)
-> ([DeleteCorsPolicy] -> ShowS)
-> Show DeleteCorsPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCorsPolicy] -> ShowS
$cshowList :: [DeleteCorsPolicy] -> ShowS
show :: DeleteCorsPolicy -> String
$cshow :: DeleteCorsPolicy -> String
showsPrec :: Int -> DeleteCorsPolicy -> ShowS
$cshowsPrec :: Int -> DeleteCorsPolicy -> ShowS
Prelude.Show, (forall x. DeleteCorsPolicy -> Rep DeleteCorsPolicy x)
-> (forall x. Rep DeleteCorsPolicy x -> DeleteCorsPolicy)
-> Generic DeleteCorsPolicy
forall x. Rep DeleteCorsPolicy x -> DeleteCorsPolicy
forall x. DeleteCorsPolicy -> Rep DeleteCorsPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCorsPolicy x -> DeleteCorsPolicy
$cfrom :: forall x. DeleteCorsPolicy -> Rep DeleteCorsPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCorsPolicy' 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:
--
-- 'containerName', 'deleteCorsPolicy_containerName' - The name of the container to remove the policy from.
newDeleteCorsPolicy ::
  -- | 'containerName'
  Prelude.Text ->
  DeleteCorsPolicy
newDeleteCorsPolicy :: Text -> DeleteCorsPolicy
newDeleteCorsPolicy Text
pContainerName_ =
  DeleteCorsPolicy' :: Text -> DeleteCorsPolicy
DeleteCorsPolicy' {$sel:containerName:DeleteCorsPolicy' :: Text
containerName = Text
pContainerName_}

-- | The name of the container to remove the policy from.
deleteCorsPolicy_containerName :: Lens.Lens' DeleteCorsPolicy Prelude.Text
deleteCorsPolicy_containerName :: (Text -> f Text) -> DeleteCorsPolicy -> f DeleteCorsPolicy
deleteCorsPolicy_containerName = (DeleteCorsPolicy -> Text)
-> (DeleteCorsPolicy -> Text -> DeleteCorsPolicy)
-> Lens DeleteCorsPolicy DeleteCorsPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCorsPolicy' {Text
containerName :: Text
$sel:containerName:DeleteCorsPolicy' :: DeleteCorsPolicy -> Text
containerName} -> Text
containerName) (\s :: DeleteCorsPolicy
s@DeleteCorsPolicy' {} Text
a -> DeleteCorsPolicy
s {$sel:containerName:DeleteCorsPolicy' :: Text
containerName = Text
a} :: DeleteCorsPolicy)

instance Core.AWSRequest DeleteCorsPolicy where
  type
    AWSResponse DeleteCorsPolicy =
      DeleteCorsPolicyResponse
  request :: DeleteCorsPolicy -> Request DeleteCorsPolicy
request = Service -> DeleteCorsPolicy -> Request DeleteCorsPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCorsPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteCorsPolicy))
-> Logger
-> Service
-> Proxy DeleteCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCorsPolicy)))
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 -> DeleteCorsPolicyResponse
DeleteCorsPolicyResponse'
            (Int -> DeleteCorsPolicyResponse)
-> Either String Int -> Either String DeleteCorsPolicyResponse
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 DeleteCorsPolicy

instance Prelude.NFData DeleteCorsPolicy

instance Core.ToHeaders DeleteCorsPolicy where
  toHeaders :: DeleteCorsPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteCorsPolicy -> 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
"MediaStore_20170901.DeleteCorsPolicy" ::
                          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 DeleteCorsPolicy where
  toJSON :: DeleteCorsPolicy -> Value
toJSON DeleteCorsPolicy' {Text
containerName :: Text
$sel:containerName:DeleteCorsPolicy' :: DeleteCorsPolicy -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContainerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteCorsPolicyResponse