{-# 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.Mobile.DeleteProject
-- 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)
--
-- Delets a project in AWS Mobile Hub.
module Amazonka.Mobile.DeleteProject
  ( -- * Creating a Request
    DeleteProject (..),
    newDeleteProject,

    -- * Request Lenses
    deleteProject_projectId,

    -- * Destructuring the Response
    DeleteProjectResponse (..),
    newDeleteProjectResponse,

    -- * Response Lenses
    deleteProjectResponse_deletedResources,
    deleteProjectResponse_orphanedResources,
    deleteProjectResponse_httpStatus,
  )
where

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

-- | Request structure used to request a project be deleted.
--
-- /See:/ 'newDeleteProject' smart constructor.
data DeleteProject = DeleteProject'
  { -- | Unique project identifier.
    DeleteProject -> Text
projectId :: Prelude.Text
  }
  deriving (DeleteProject -> DeleteProject -> Bool
(DeleteProject -> DeleteProject -> Bool)
-> (DeleteProject -> DeleteProject -> Bool) -> Eq DeleteProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProject -> DeleteProject -> Bool
$c/= :: DeleteProject -> DeleteProject -> Bool
== :: DeleteProject -> DeleteProject -> Bool
$c== :: DeleteProject -> DeleteProject -> Bool
Prelude.Eq, ReadPrec [DeleteProject]
ReadPrec DeleteProject
Int -> ReadS DeleteProject
ReadS [DeleteProject]
(Int -> ReadS DeleteProject)
-> ReadS [DeleteProject]
-> ReadPrec DeleteProject
-> ReadPrec [DeleteProject]
-> Read DeleteProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProject]
$creadListPrec :: ReadPrec [DeleteProject]
readPrec :: ReadPrec DeleteProject
$creadPrec :: ReadPrec DeleteProject
readList :: ReadS [DeleteProject]
$creadList :: ReadS [DeleteProject]
readsPrec :: Int -> ReadS DeleteProject
$creadsPrec :: Int -> ReadS DeleteProject
Prelude.Read, Int -> DeleteProject -> ShowS
[DeleteProject] -> ShowS
DeleteProject -> String
(Int -> DeleteProject -> ShowS)
-> (DeleteProject -> String)
-> ([DeleteProject] -> ShowS)
-> Show DeleteProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProject] -> ShowS
$cshowList :: [DeleteProject] -> ShowS
show :: DeleteProject -> String
$cshow :: DeleteProject -> String
showsPrec :: Int -> DeleteProject -> ShowS
$cshowsPrec :: Int -> DeleteProject -> ShowS
Prelude.Show, (forall x. DeleteProject -> Rep DeleteProject x)
-> (forall x. Rep DeleteProject x -> DeleteProject)
-> Generic DeleteProject
forall x. Rep DeleteProject x -> DeleteProject
forall x. DeleteProject -> Rep DeleteProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProject x -> DeleteProject
$cfrom :: forall x. DeleteProject -> Rep DeleteProject x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProject' 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:
--
-- 'projectId', 'deleteProject_projectId' - Unique project identifier.
newDeleteProject ::
  -- | 'projectId'
  Prelude.Text ->
  DeleteProject
newDeleteProject :: Text -> DeleteProject
newDeleteProject Text
pProjectId_ =
  DeleteProject' :: Text -> DeleteProject
DeleteProject' {$sel:projectId:DeleteProject' :: Text
projectId = Text
pProjectId_}

-- | Unique project identifier.
deleteProject_projectId :: Lens.Lens' DeleteProject Prelude.Text
deleteProject_projectId :: (Text -> f Text) -> DeleteProject -> f DeleteProject
deleteProject_projectId = (DeleteProject -> Text)
-> (DeleteProject -> Text -> DeleteProject)
-> Lens DeleteProject DeleteProject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProject' {Text
projectId :: Text
$sel:projectId:DeleteProject' :: DeleteProject -> Text
projectId} -> Text
projectId) (\s :: DeleteProject
s@DeleteProject' {} Text
a -> DeleteProject
s {$sel:projectId:DeleteProject' :: Text
projectId = Text
a} :: DeleteProject)

instance Core.AWSRequest DeleteProject where
  type
    AWSResponse DeleteProject =
      DeleteProjectResponse
  request :: DeleteProject -> Request DeleteProject
request = Service -> DeleteProject -> Request DeleteProject
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProject)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteProject))
-> Logger
-> Service
-> Proxy DeleteProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Resource]
-> Maybe [Resource] -> Int -> DeleteProjectResponse
DeleteProjectResponse'
            (Maybe [Resource]
 -> Maybe [Resource] -> Int -> DeleteProjectResponse)
-> Either String (Maybe [Resource])
-> Either String (Maybe [Resource] -> Int -> DeleteProjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Resource]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deletedResources"
                            Either String (Maybe (Maybe [Resource]))
-> Maybe [Resource] -> Either String (Maybe [Resource])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Resource]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe [Resource] -> Int -> DeleteProjectResponse)
-> Either String (Maybe [Resource])
-> Either String (Int -> DeleteProjectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Resource]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"orphanedResources"
                            Either String (Maybe (Maybe [Resource]))
-> Maybe [Resource] -> Either String (Maybe [Resource])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Resource]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DeleteProjectResponse)
-> Either String Int -> Either String DeleteProjectResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteProject

instance Prelude.NFData DeleteProject

instance Core.ToHeaders DeleteProject where
  toHeaders :: DeleteProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteProject -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteProject where
  toPath :: DeleteProject -> ByteString
toPath DeleteProject' {Text
projectId :: Text
$sel:projectId:DeleteProject' :: DeleteProject -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/projects/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectId]

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

-- | Result structure used in response to request to delete a project.
--
-- /See:/ 'newDeleteProjectResponse' smart constructor.
data DeleteProjectResponse = DeleteProjectResponse'
  { -- | Resources which were deleted.
    DeleteProjectResponse -> Maybe [Resource]
deletedResources :: Prelude.Maybe [Resource],
    -- | Resources which were not deleted, due to a risk of losing potentially
    -- important data or files.
    DeleteProjectResponse -> Maybe [Resource]
orphanedResources :: Prelude.Maybe [Resource],
    -- | The response's http status code.
    DeleteProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteProjectResponse -> DeleteProjectResponse -> Bool
(DeleteProjectResponse -> DeleteProjectResponse -> Bool)
-> (DeleteProjectResponse -> DeleteProjectResponse -> Bool)
-> Eq DeleteProjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
$c/= :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
== :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
$c== :: DeleteProjectResponse -> DeleteProjectResponse -> Bool
Prelude.Eq, ReadPrec [DeleteProjectResponse]
ReadPrec DeleteProjectResponse
Int -> ReadS DeleteProjectResponse
ReadS [DeleteProjectResponse]
(Int -> ReadS DeleteProjectResponse)
-> ReadS [DeleteProjectResponse]
-> ReadPrec DeleteProjectResponse
-> ReadPrec [DeleteProjectResponse]
-> Read DeleteProjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProjectResponse]
$creadListPrec :: ReadPrec [DeleteProjectResponse]
readPrec :: ReadPrec DeleteProjectResponse
$creadPrec :: ReadPrec DeleteProjectResponse
readList :: ReadS [DeleteProjectResponse]
$creadList :: ReadS [DeleteProjectResponse]
readsPrec :: Int -> ReadS DeleteProjectResponse
$creadsPrec :: Int -> ReadS DeleteProjectResponse
Prelude.Read, Int -> DeleteProjectResponse -> ShowS
[DeleteProjectResponse] -> ShowS
DeleteProjectResponse -> String
(Int -> DeleteProjectResponse -> ShowS)
-> (DeleteProjectResponse -> String)
-> ([DeleteProjectResponse] -> ShowS)
-> Show DeleteProjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProjectResponse] -> ShowS
$cshowList :: [DeleteProjectResponse] -> ShowS
show :: DeleteProjectResponse -> String
$cshow :: DeleteProjectResponse -> String
showsPrec :: Int -> DeleteProjectResponse -> ShowS
$cshowsPrec :: Int -> DeleteProjectResponse -> ShowS
Prelude.Show, (forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x)
-> (forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse)
-> Generic DeleteProjectResponse
forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse
forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProjectResponse x -> DeleteProjectResponse
$cfrom :: forall x. DeleteProjectResponse -> Rep DeleteProjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProjectResponse' 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:
--
-- 'deletedResources', 'deleteProjectResponse_deletedResources' - Resources which were deleted.
--
-- 'orphanedResources', 'deleteProjectResponse_orphanedResources' - Resources which were not deleted, due to a risk of losing potentially
-- important data or files.
--
-- 'httpStatus', 'deleteProjectResponse_httpStatus' - The response's http status code.
newDeleteProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteProjectResponse
newDeleteProjectResponse :: Int -> DeleteProjectResponse
newDeleteProjectResponse Int
pHttpStatus_ =
  DeleteProjectResponse' :: Maybe [Resource]
-> Maybe [Resource] -> Int -> DeleteProjectResponse
DeleteProjectResponse'
    { $sel:deletedResources:DeleteProjectResponse' :: Maybe [Resource]
deletedResources =
        Maybe [Resource]
forall a. Maybe a
Prelude.Nothing,
      $sel:orphanedResources:DeleteProjectResponse' :: Maybe [Resource]
orphanedResources = Maybe [Resource]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Resources which were deleted.
deleteProjectResponse_deletedResources :: Lens.Lens' DeleteProjectResponse (Prelude.Maybe [Resource])
deleteProjectResponse_deletedResources :: (Maybe [Resource] -> f (Maybe [Resource]))
-> DeleteProjectResponse -> f DeleteProjectResponse
deleteProjectResponse_deletedResources = (DeleteProjectResponse -> Maybe [Resource])
-> (DeleteProjectResponse
    -> Maybe [Resource] -> DeleteProjectResponse)
-> Lens
     DeleteProjectResponse
     DeleteProjectResponse
     (Maybe [Resource])
     (Maybe [Resource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProjectResponse' {Maybe [Resource]
deletedResources :: Maybe [Resource]
$sel:deletedResources:DeleteProjectResponse' :: DeleteProjectResponse -> Maybe [Resource]
deletedResources} -> Maybe [Resource]
deletedResources) (\s :: DeleteProjectResponse
s@DeleteProjectResponse' {} Maybe [Resource]
a -> DeleteProjectResponse
s {$sel:deletedResources:DeleteProjectResponse' :: Maybe [Resource]
deletedResources = Maybe [Resource]
a} :: DeleteProjectResponse) ((Maybe [Resource] -> f (Maybe [Resource]))
 -> DeleteProjectResponse -> f DeleteProjectResponse)
-> ((Maybe [Resource] -> f (Maybe [Resource]))
    -> Maybe [Resource] -> f (Maybe [Resource]))
-> (Maybe [Resource] -> f (Maybe [Resource]))
-> DeleteProjectResponse
-> f DeleteProjectResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Resource] [Resource] [Resource] [Resource]
-> Iso
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Resource] [Resource] [Resource] [Resource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Resources which were not deleted, due to a risk of losing potentially
-- important data or files.
deleteProjectResponse_orphanedResources :: Lens.Lens' DeleteProjectResponse (Prelude.Maybe [Resource])
deleteProjectResponse_orphanedResources :: (Maybe [Resource] -> f (Maybe [Resource]))
-> DeleteProjectResponse -> f DeleteProjectResponse
deleteProjectResponse_orphanedResources = (DeleteProjectResponse -> Maybe [Resource])
-> (DeleteProjectResponse
    -> Maybe [Resource] -> DeleteProjectResponse)
-> Lens
     DeleteProjectResponse
     DeleteProjectResponse
     (Maybe [Resource])
     (Maybe [Resource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProjectResponse' {Maybe [Resource]
orphanedResources :: Maybe [Resource]
$sel:orphanedResources:DeleteProjectResponse' :: DeleteProjectResponse -> Maybe [Resource]
orphanedResources} -> Maybe [Resource]
orphanedResources) (\s :: DeleteProjectResponse
s@DeleteProjectResponse' {} Maybe [Resource]
a -> DeleteProjectResponse
s {$sel:orphanedResources:DeleteProjectResponse' :: Maybe [Resource]
orphanedResources = Maybe [Resource]
a} :: DeleteProjectResponse) ((Maybe [Resource] -> f (Maybe [Resource]))
 -> DeleteProjectResponse -> f DeleteProjectResponse)
-> ((Maybe [Resource] -> f (Maybe [Resource]))
    -> Maybe [Resource] -> f (Maybe [Resource]))
-> (Maybe [Resource] -> f (Maybe [Resource]))
-> DeleteProjectResponse
-> f DeleteProjectResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Resource] [Resource] [Resource] [Resource]
-> Iso
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Resource] [Resource] [Resource] [Resource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteProjectResponse