{-# 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.AppStream.DeleteImagePermissions
-- 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 permissions for the specified private image. After you delete
-- permissions for an image, AWS accounts to which you previously granted
-- these permissions can no longer use the image.
module Amazonka.AppStream.DeleteImagePermissions
  ( -- * Creating a Request
    DeleteImagePermissions (..),
    newDeleteImagePermissions,

    -- * Request Lenses
    deleteImagePermissions_name,
    deleteImagePermissions_sharedAccountId,

    -- * Destructuring the Response
    DeleteImagePermissionsResponse (..),
    newDeleteImagePermissionsResponse,

    -- * Response Lenses
    deleteImagePermissionsResponse_httpStatus,
  )
where

import Amazonka.AppStream.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteImagePermissions' smart constructor.
data DeleteImagePermissions = DeleteImagePermissions'
  { -- | The name of the private image.
    DeleteImagePermissions -> Text
name :: Prelude.Text,
    -- | The 12-digit identifier of the AWS account for which to delete image
    -- permissions.
    DeleteImagePermissions -> Text
sharedAccountId :: Prelude.Text
  }
  deriving (DeleteImagePermissions -> DeleteImagePermissions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteImagePermissions -> DeleteImagePermissions -> Bool
$c/= :: DeleteImagePermissions -> DeleteImagePermissions -> Bool
== :: DeleteImagePermissions -> DeleteImagePermissions -> Bool
$c== :: DeleteImagePermissions -> DeleteImagePermissions -> Bool
Prelude.Eq, ReadPrec [DeleteImagePermissions]
ReadPrec DeleteImagePermissions
Int -> ReadS DeleteImagePermissions
ReadS [DeleteImagePermissions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteImagePermissions]
$creadListPrec :: ReadPrec [DeleteImagePermissions]
readPrec :: ReadPrec DeleteImagePermissions
$creadPrec :: ReadPrec DeleteImagePermissions
readList :: ReadS [DeleteImagePermissions]
$creadList :: ReadS [DeleteImagePermissions]
readsPrec :: Int -> ReadS DeleteImagePermissions
$creadsPrec :: Int -> ReadS DeleteImagePermissions
Prelude.Read, Int -> DeleteImagePermissions -> ShowS
[DeleteImagePermissions] -> ShowS
DeleteImagePermissions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteImagePermissions] -> ShowS
$cshowList :: [DeleteImagePermissions] -> ShowS
show :: DeleteImagePermissions -> String
$cshow :: DeleteImagePermissions -> String
showsPrec :: Int -> DeleteImagePermissions -> ShowS
$cshowsPrec :: Int -> DeleteImagePermissions -> ShowS
Prelude.Show, forall x. Rep DeleteImagePermissions x -> DeleteImagePermissions
forall x. DeleteImagePermissions -> Rep DeleteImagePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteImagePermissions x -> DeleteImagePermissions
$cfrom :: forall x. DeleteImagePermissions -> Rep DeleteImagePermissions x
Prelude.Generic)

-- |
-- Create a value of 'DeleteImagePermissions' 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:
--
-- 'name', 'deleteImagePermissions_name' - The name of the private image.
--
-- 'sharedAccountId', 'deleteImagePermissions_sharedAccountId' - The 12-digit identifier of the AWS account for which to delete image
-- permissions.
newDeleteImagePermissions ::
  -- | 'name'
  Prelude.Text ->
  -- | 'sharedAccountId'
  Prelude.Text ->
  DeleteImagePermissions
newDeleteImagePermissions :: Text -> Text -> DeleteImagePermissions
newDeleteImagePermissions Text
pName_ Text
pSharedAccountId_ =
  DeleteImagePermissions'
    { $sel:name:DeleteImagePermissions' :: Text
name = Text
pName_,
      $sel:sharedAccountId:DeleteImagePermissions' :: Text
sharedAccountId = Text
pSharedAccountId_
    }

-- | The name of the private image.
deleteImagePermissions_name :: Lens.Lens' DeleteImagePermissions Prelude.Text
deleteImagePermissions_name :: Lens' DeleteImagePermissions Text
deleteImagePermissions_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImagePermissions' {Text
name :: Text
$sel:name:DeleteImagePermissions' :: DeleteImagePermissions -> Text
name} -> Text
name) (\s :: DeleteImagePermissions
s@DeleteImagePermissions' {} Text
a -> DeleteImagePermissions
s {$sel:name:DeleteImagePermissions' :: Text
name = Text
a} :: DeleteImagePermissions)

-- | The 12-digit identifier of the AWS account for which to delete image
-- permissions.
deleteImagePermissions_sharedAccountId :: Lens.Lens' DeleteImagePermissions Prelude.Text
deleteImagePermissions_sharedAccountId :: Lens' DeleteImagePermissions Text
deleteImagePermissions_sharedAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImagePermissions' {Text
sharedAccountId :: Text
$sel:sharedAccountId:DeleteImagePermissions' :: DeleteImagePermissions -> Text
sharedAccountId} -> Text
sharedAccountId) (\s :: DeleteImagePermissions
s@DeleteImagePermissions' {} Text
a -> DeleteImagePermissions
s {$sel:sharedAccountId:DeleteImagePermissions' :: Text
sharedAccountId = Text
a} :: DeleteImagePermissions)

instance Core.AWSRequest DeleteImagePermissions where
  type
    AWSResponse DeleteImagePermissions =
      DeleteImagePermissionsResponse
  request :: (Service -> Service)
-> DeleteImagePermissions -> Request DeleteImagePermissions
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 DeleteImagePermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteImagePermissions)))
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 -> DeleteImagePermissionsResponse
DeleteImagePermissionsResponse'
            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 DeleteImagePermissions where
  hashWithSalt :: Int -> DeleteImagePermissions -> Int
hashWithSalt Int
_salt DeleteImagePermissions' {Text
sharedAccountId :: Text
name :: Text
$sel:sharedAccountId:DeleteImagePermissions' :: DeleteImagePermissions -> Text
$sel:name:DeleteImagePermissions' :: DeleteImagePermissions -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sharedAccountId

instance Prelude.NFData DeleteImagePermissions where
  rnf :: DeleteImagePermissions -> ()
rnf DeleteImagePermissions' {Text
sharedAccountId :: Text
name :: Text
$sel:sharedAccountId:DeleteImagePermissions' :: DeleteImagePermissions -> Text
$sel:name:DeleteImagePermissions' :: DeleteImagePermissions -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sharedAccountId

instance Data.ToHeaders DeleteImagePermissions where
  toHeaders :: DeleteImagePermissions -> 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
"PhotonAdminProxyService.DeleteImagePermissions" ::
                          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 DeleteImagePermissions where
  toJSON :: DeleteImagePermissions -> Value
toJSON DeleteImagePermissions' {Text
sharedAccountId :: Text
name :: Text
$sel:sharedAccountId:DeleteImagePermissions' :: DeleteImagePermissions -> Text
$sel:name:DeleteImagePermissions' :: DeleteImagePermissions -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SharedAccountId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sharedAccountId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteImagePermissionsResponse
  where
  rnf :: DeleteImagePermissionsResponse -> ()
rnf DeleteImagePermissionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteImagePermissionsResponse' :: DeleteImagePermissionsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus