{-# 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.UpdateImagePermissions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds or updates permissions for the specified private image.
module Amazonka.AppStream.UpdateImagePermissions
  ( -- * Creating a Request
    UpdateImagePermissions (..),
    newUpdateImagePermissions,

    -- * Request Lenses
    updateImagePermissions_name,
    updateImagePermissions_sharedAccountId,
    updateImagePermissions_imagePermissions,

    -- * Destructuring the Response
    UpdateImagePermissionsResponse (..),
    newUpdateImagePermissionsResponse,

    -- * Response Lenses
    updateImagePermissionsResponse_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:/ 'newUpdateImagePermissions' smart constructor.
data UpdateImagePermissions = UpdateImagePermissions'
  { -- | The name of the private image.
    UpdateImagePermissions -> Text
name :: Prelude.Text,
    -- | The 12-digit identifier of the AWS account for which you want add or
    -- update image permissions.
    UpdateImagePermissions -> Text
sharedAccountId :: Prelude.Text,
    -- | The permissions for the image.
    UpdateImagePermissions -> ImagePermissions
imagePermissions :: ImagePermissions
  }
  deriving (UpdateImagePermissions -> UpdateImagePermissions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateImagePermissions -> UpdateImagePermissions -> Bool
$c/= :: UpdateImagePermissions -> UpdateImagePermissions -> Bool
== :: UpdateImagePermissions -> UpdateImagePermissions -> Bool
$c== :: UpdateImagePermissions -> UpdateImagePermissions -> Bool
Prelude.Eq, ReadPrec [UpdateImagePermissions]
ReadPrec UpdateImagePermissions
Int -> ReadS UpdateImagePermissions
ReadS [UpdateImagePermissions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateImagePermissions]
$creadListPrec :: ReadPrec [UpdateImagePermissions]
readPrec :: ReadPrec UpdateImagePermissions
$creadPrec :: ReadPrec UpdateImagePermissions
readList :: ReadS [UpdateImagePermissions]
$creadList :: ReadS [UpdateImagePermissions]
readsPrec :: Int -> ReadS UpdateImagePermissions
$creadsPrec :: Int -> ReadS UpdateImagePermissions
Prelude.Read, Int -> UpdateImagePermissions -> ShowS
[UpdateImagePermissions] -> ShowS
UpdateImagePermissions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateImagePermissions] -> ShowS
$cshowList :: [UpdateImagePermissions] -> ShowS
show :: UpdateImagePermissions -> String
$cshow :: UpdateImagePermissions -> String
showsPrec :: Int -> UpdateImagePermissions -> ShowS
$cshowsPrec :: Int -> UpdateImagePermissions -> ShowS
Prelude.Show, forall x. Rep UpdateImagePermissions x -> UpdateImagePermissions
forall x. UpdateImagePermissions -> Rep UpdateImagePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateImagePermissions x -> UpdateImagePermissions
$cfrom :: forall x. UpdateImagePermissions -> Rep UpdateImagePermissions x
Prelude.Generic)

-- |
-- Create a value of 'UpdateImagePermissions' 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', 'updateImagePermissions_name' - The name of the private image.
--
-- 'sharedAccountId', 'updateImagePermissions_sharedAccountId' - The 12-digit identifier of the AWS account for which you want add or
-- update image permissions.
--
-- 'imagePermissions', 'updateImagePermissions_imagePermissions' - The permissions for the image.
newUpdateImagePermissions ::
  -- | 'name'
  Prelude.Text ->
  -- | 'sharedAccountId'
  Prelude.Text ->
  -- | 'imagePermissions'
  ImagePermissions ->
  UpdateImagePermissions
newUpdateImagePermissions :: Text -> Text -> ImagePermissions -> UpdateImagePermissions
newUpdateImagePermissions
  Text
pName_
  Text
pSharedAccountId_
  ImagePermissions
pImagePermissions_ =
    UpdateImagePermissions'
      { $sel:name:UpdateImagePermissions' :: Text
name = Text
pName_,
        $sel:sharedAccountId:UpdateImagePermissions' :: Text
sharedAccountId = Text
pSharedAccountId_,
        $sel:imagePermissions:UpdateImagePermissions' :: ImagePermissions
imagePermissions = ImagePermissions
pImagePermissions_
      }

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

-- | The 12-digit identifier of the AWS account for which you want add or
-- update image permissions.
updateImagePermissions_sharedAccountId :: Lens.Lens' UpdateImagePermissions Prelude.Text
updateImagePermissions_sharedAccountId :: Lens' UpdateImagePermissions Text
updateImagePermissions_sharedAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImagePermissions' {Text
sharedAccountId :: Text
$sel:sharedAccountId:UpdateImagePermissions' :: UpdateImagePermissions -> Text
sharedAccountId} -> Text
sharedAccountId) (\s :: UpdateImagePermissions
s@UpdateImagePermissions' {} Text
a -> UpdateImagePermissions
s {$sel:sharedAccountId:UpdateImagePermissions' :: Text
sharedAccountId = Text
a} :: UpdateImagePermissions)

-- | The permissions for the image.
updateImagePermissions_imagePermissions :: Lens.Lens' UpdateImagePermissions ImagePermissions
updateImagePermissions_imagePermissions :: Lens' UpdateImagePermissions ImagePermissions
updateImagePermissions_imagePermissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImagePermissions' {ImagePermissions
imagePermissions :: ImagePermissions
$sel:imagePermissions:UpdateImagePermissions' :: UpdateImagePermissions -> ImagePermissions
imagePermissions} -> ImagePermissions
imagePermissions) (\s :: UpdateImagePermissions
s@UpdateImagePermissions' {} ImagePermissions
a -> UpdateImagePermissions
s {$sel:imagePermissions:UpdateImagePermissions' :: ImagePermissions
imagePermissions = ImagePermissions
a} :: UpdateImagePermissions)

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

instance Prelude.NFData UpdateImagePermissions where
  rnf :: UpdateImagePermissions -> ()
rnf UpdateImagePermissions' {Text
ImagePermissions
imagePermissions :: ImagePermissions
sharedAccountId :: Text
name :: Text
$sel:imagePermissions:UpdateImagePermissions' :: UpdateImagePermissions -> ImagePermissions
$sel:sharedAccountId:UpdateImagePermissions' :: UpdateImagePermissions -> Text
$sel:name:UpdateImagePermissions' :: UpdateImagePermissions -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ImagePermissions
imagePermissions

instance Data.ToHeaders UpdateImagePermissions where
  toHeaders :: UpdateImagePermissions -> 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.UpdateImagePermissions" ::
                          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 UpdateImagePermissions where
  toJSON :: UpdateImagePermissions -> Value
toJSON UpdateImagePermissions' {Text
ImagePermissions
imagePermissions :: ImagePermissions
sharedAccountId :: Text
name :: Text
$sel:imagePermissions:UpdateImagePermissions' :: UpdateImagePermissions -> ImagePermissions
$sel:sharedAccountId:UpdateImagePermissions' :: UpdateImagePermissions -> Text
$sel:name:UpdateImagePermissions' :: UpdateImagePermissions -> 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),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ImagePermissions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImagePermissions
imagePermissions)
          ]
      )

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

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

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

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

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

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