{-# 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-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 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.Lens as Lens
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
(DeleteImagePermissions -> DeleteImagePermissions -> Bool)
-> (DeleteImagePermissions -> DeleteImagePermissions -> Bool)
-> Eq DeleteImagePermissions
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]
(Int -> ReadS DeleteImagePermissions)
-> ReadS [DeleteImagePermissions]
-> ReadPrec DeleteImagePermissions
-> ReadPrec [DeleteImagePermissions]
-> Read 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
(Int -> DeleteImagePermissions -> ShowS)
-> (DeleteImagePermissions -> String)
-> ([DeleteImagePermissions] -> ShowS)
-> Show DeleteImagePermissions
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. DeleteImagePermissions -> Rep DeleteImagePermissions x)
-> (forall x.
    Rep DeleteImagePermissions x -> DeleteImagePermissions)
-> Generic DeleteImagePermissions
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' :: Text -> Text -> DeleteImagePermissions
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 :: (Text -> f Text)
-> DeleteImagePermissions -> f DeleteImagePermissions
deleteImagePermissions_name = (DeleteImagePermissions -> Text)
-> (DeleteImagePermissions -> Text -> DeleteImagePermissions)
-> Lens DeleteImagePermissions DeleteImagePermissions Text Text
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 :: (Text -> f Text)
-> DeleteImagePermissions -> f DeleteImagePermissions
deleteImagePermissions_sharedAccountId = (DeleteImagePermissions -> Text)
-> (DeleteImagePermissions -> Text -> DeleteImagePermissions)
-> Lens DeleteImagePermissions DeleteImagePermissions Text Text
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 :: DeleteImagePermissions -> Request DeleteImagePermissions
request = Service -> DeleteImagePermissions -> Request DeleteImagePermissions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteImagePermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteImagePermissions)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteImagePermissions))
-> Logger
-> Service
-> Proxy DeleteImagePermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteImagePermissions)))
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 -> DeleteImagePermissionsResponse
DeleteImagePermissionsResponse'
            (Int -> DeleteImagePermissionsResponse)
-> Either String Int
-> Either String DeleteImagePermissionsResponse
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 DeleteImagePermissions

instance Prelude.NFData DeleteImagePermissions

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

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

instance Core.ToQuery DeleteImagePermissions where
  toQuery :: DeleteImagePermissions -> QueryString
toQuery = QueryString -> DeleteImagePermissions -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteImagePermissionsResponse
 -> DeleteImagePermissionsResponse -> Bool)
-> (DeleteImagePermissionsResponse
    -> DeleteImagePermissionsResponse -> Bool)
-> Eq DeleteImagePermissionsResponse
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]
(Int -> ReadS DeleteImagePermissionsResponse)
-> ReadS [DeleteImagePermissionsResponse]
-> ReadPrec DeleteImagePermissionsResponse
-> ReadPrec [DeleteImagePermissionsResponse]
-> Read 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
(Int -> DeleteImagePermissionsResponse -> ShowS)
-> (DeleteImagePermissionsResponse -> String)
-> ([DeleteImagePermissionsResponse] -> ShowS)
-> Show DeleteImagePermissionsResponse
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.
 DeleteImagePermissionsResponse
 -> Rep DeleteImagePermissionsResponse x)
-> (forall x.
    Rep DeleteImagePermissionsResponse x
    -> DeleteImagePermissionsResponse)
-> Generic DeleteImagePermissionsResponse
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' :: Int -> DeleteImagePermissionsResponse
DeleteImagePermissionsResponse'
    { $sel:httpStatus:DeleteImagePermissionsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteImagePermissionsResponse_httpStatus :: Lens.Lens' DeleteImagePermissionsResponse Prelude.Int
deleteImagePermissionsResponse_httpStatus :: (Int -> f Int)
-> DeleteImagePermissionsResponse
-> f DeleteImagePermissionsResponse
deleteImagePermissionsResponse_httpStatus = (DeleteImagePermissionsResponse -> Int)
-> (DeleteImagePermissionsResponse
    -> Int -> DeleteImagePermissionsResponse)
-> Lens
     DeleteImagePermissionsResponse
     DeleteImagePermissionsResponse
     Int
     Int
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