{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' DeleteCorsPolicy Text
deleteCorsPolicy_containerName = 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 :: (Service -> Service)
-> DeleteCorsPolicy -> Request DeleteCorsPolicy
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteCorsPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteCorsPolicyResponse
DeleteCorsPolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteCorsPolicy where
  hashWithSalt :: Int -> DeleteCorsPolicy -> Int
hashWithSalt Int
_salt DeleteCorsPolicy' {Text
containerName :: Text
$sel:containerName:DeleteCorsPolicy' :: DeleteCorsPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
containerName

instance Prelude.NFData DeleteCorsPolicy where
  rnf :: DeleteCorsPolicy -> ()
rnf DeleteCorsPolicy' {Text
containerName :: Text
$sel:containerName:DeleteCorsPolicy' :: DeleteCorsPolicy -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
containerName

instance Data.ToHeaders DeleteCorsPolicy where
  toHeaders :: DeleteCorsPolicy -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"MediaStore_20170901.DeleteCorsPolicy" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteCorsPolicy where
  toJSON :: DeleteCorsPolicy -> Value
toJSON DeleteCorsPolicy' {Text
containerName :: Text
$sel:containerName:DeleteCorsPolicy' :: DeleteCorsPolicy -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ContainerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
containerName)
          ]
      )

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

instance Data.ToQuery DeleteCorsPolicy where
  toQuery :: DeleteCorsPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:DeleteCorsPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteCorsPolicyResponse_httpStatus :: Lens.Lens' DeleteCorsPolicyResponse Prelude.Int
deleteCorsPolicyResponse_httpStatus :: Lens' DeleteCorsPolicyResponse Int
deleteCorsPolicyResponse_httpStatus = 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 where
  rnf :: DeleteCorsPolicyResponse -> ()
rnf DeleteCorsPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteCorsPolicyResponse' :: DeleteCorsPolicyResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus