{-# 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.Proton.DeleteRepository
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- De-register and unlink your repository.
module Amazonka.Proton.DeleteRepository
  ( -- * Creating a Request
    DeleteRepository (..),
    newDeleteRepository,

    -- * Request Lenses
    deleteRepository_name,
    deleteRepository_provider,

    -- * Destructuring the Response
    DeleteRepositoryResponse (..),
    newDeleteRepositoryResponse,

    -- * Response Lenses
    deleteRepositoryResponse_repository,
    deleteRepositoryResponse_httpStatus,
  )
where

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 Amazonka.Proton.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteRepository' smart constructor.
data DeleteRepository = DeleteRepository'
  { -- | The repository name.
    DeleteRepository -> Text
name :: Prelude.Text,
    -- | The repository provider.
    DeleteRepository -> RepositoryProvider
provider :: RepositoryProvider
  }
  deriving (DeleteRepository -> DeleteRepository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRepository -> DeleteRepository -> Bool
$c/= :: DeleteRepository -> DeleteRepository -> Bool
== :: DeleteRepository -> DeleteRepository -> Bool
$c== :: DeleteRepository -> DeleteRepository -> Bool
Prelude.Eq, ReadPrec [DeleteRepository]
ReadPrec DeleteRepository
Int -> ReadS DeleteRepository
ReadS [DeleteRepository]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRepository]
$creadListPrec :: ReadPrec [DeleteRepository]
readPrec :: ReadPrec DeleteRepository
$creadPrec :: ReadPrec DeleteRepository
readList :: ReadS [DeleteRepository]
$creadList :: ReadS [DeleteRepository]
readsPrec :: Int -> ReadS DeleteRepository
$creadsPrec :: Int -> ReadS DeleteRepository
Prelude.Read, Int -> DeleteRepository -> ShowS
[DeleteRepository] -> ShowS
DeleteRepository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRepository] -> ShowS
$cshowList :: [DeleteRepository] -> ShowS
show :: DeleteRepository -> String
$cshow :: DeleteRepository -> String
showsPrec :: Int -> DeleteRepository -> ShowS
$cshowsPrec :: Int -> DeleteRepository -> ShowS
Prelude.Show, forall x. Rep DeleteRepository x -> DeleteRepository
forall x. DeleteRepository -> Rep DeleteRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRepository x -> DeleteRepository
$cfrom :: forall x. DeleteRepository -> Rep DeleteRepository x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRepository' 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', 'deleteRepository_name' - The repository name.
--
-- 'provider', 'deleteRepository_provider' - The repository provider.
newDeleteRepository ::
  -- | 'name'
  Prelude.Text ->
  -- | 'provider'
  RepositoryProvider ->
  DeleteRepository
newDeleteRepository :: Text -> RepositoryProvider -> DeleteRepository
newDeleteRepository Text
pName_ RepositoryProvider
pProvider_ =
  DeleteRepository'
    { $sel:name:DeleteRepository' :: Text
name = Text
pName_,
      $sel:provider:DeleteRepository' :: RepositoryProvider
provider = RepositoryProvider
pProvider_
    }

-- | The repository name.
deleteRepository_name :: Lens.Lens' DeleteRepository Prelude.Text
deleteRepository_name :: Lens' DeleteRepository Text
deleteRepository_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepository' {Text
name :: Text
$sel:name:DeleteRepository' :: DeleteRepository -> Text
name} -> Text
name) (\s :: DeleteRepository
s@DeleteRepository' {} Text
a -> DeleteRepository
s {$sel:name:DeleteRepository' :: Text
name = Text
a} :: DeleteRepository)

-- | The repository provider.
deleteRepository_provider :: Lens.Lens' DeleteRepository RepositoryProvider
deleteRepository_provider :: Lens' DeleteRepository RepositoryProvider
deleteRepository_provider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepository' {RepositoryProvider
provider :: RepositoryProvider
$sel:provider:DeleteRepository' :: DeleteRepository -> RepositoryProvider
provider} -> RepositoryProvider
provider) (\s :: DeleteRepository
s@DeleteRepository' {} RepositoryProvider
a -> DeleteRepository
s {$sel:provider:DeleteRepository' :: RepositoryProvider
provider = RepositoryProvider
a} :: DeleteRepository)

instance Core.AWSRequest DeleteRepository where
  type
    AWSResponse DeleteRepository =
      DeleteRepositoryResponse
  request :: (Service -> Service)
-> DeleteRepository -> Request DeleteRepository
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 DeleteRepository
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteRepository)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Repository -> Int -> DeleteRepositoryResponse
DeleteRepositoryResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"repository")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteRepository where
  hashWithSalt :: Int -> DeleteRepository -> Int
hashWithSalt Int
_salt DeleteRepository' {Text
RepositoryProvider
provider :: RepositoryProvider
name :: Text
$sel:provider:DeleteRepository' :: DeleteRepository -> RepositoryProvider
$sel:name:DeleteRepository' :: DeleteRepository -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RepositoryProvider
provider

instance Prelude.NFData DeleteRepository where
  rnf :: DeleteRepository -> ()
rnf DeleteRepository' {Text
RepositoryProvider
provider :: RepositoryProvider
name :: Text
$sel:provider:DeleteRepository' :: DeleteRepository -> RepositoryProvider
$sel:name:DeleteRepository' :: DeleteRepository -> 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 RepositoryProvider
provider

instance Data.ToHeaders DeleteRepository where
  toHeaders :: DeleteRepository -> 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
"AwsProton20200720.DeleteRepository" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteRepository where
  toJSON :: DeleteRepository -> Value
toJSON DeleteRepository' {Text
RepositoryProvider
provider :: RepositoryProvider
name :: Text
$sel:provider:DeleteRepository' :: DeleteRepository -> RepositoryProvider
$sel:name:DeleteRepository' :: DeleteRepository -> 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
"provider" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RepositoryProvider
provider)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteRepositoryResponse' 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:
--
-- 'repository', 'deleteRepositoryResponse_repository' - The deleted repository link\'s detail data that\'s returned by Proton.
--
-- 'httpStatus', 'deleteRepositoryResponse_httpStatus' - The response's http status code.
newDeleteRepositoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRepositoryResponse
newDeleteRepositoryResponse :: Int -> DeleteRepositoryResponse
newDeleteRepositoryResponse Int
pHttpStatus_ =
  DeleteRepositoryResponse'
    { $sel:repository:DeleteRepositoryResponse' :: Maybe Repository
repository =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteRepositoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The deleted repository link\'s detail data that\'s returned by Proton.
deleteRepositoryResponse_repository :: Lens.Lens' DeleteRepositoryResponse (Prelude.Maybe Repository)
deleteRepositoryResponse_repository :: Lens' DeleteRepositoryResponse (Maybe Repository)
deleteRepositoryResponse_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepositoryResponse' {Maybe Repository
repository :: Maybe Repository
$sel:repository:DeleteRepositoryResponse' :: DeleteRepositoryResponse -> Maybe Repository
repository} -> Maybe Repository
repository) (\s :: DeleteRepositoryResponse
s@DeleteRepositoryResponse' {} Maybe Repository
a -> DeleteRepositoryResponse
s {$sel:repository:DeleteRepositoryResponse' :: Maybe Repository
repository = Maybe Repository
a} :: DeleteRepositoryResponse)

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

instance Prelude.NFData DeleteRepositoryResponse where
  rnf :: DeleteRepositoryResponse -> ()
rnf DeleteRepositoryResponse' {Int
Maybe Repository
httpStatus :: Int
repository :: Maybe Repository
$sel:httpStatus:DeleteRepositoryResponse' :: DeleteRepositoryResponse -> Int
$sel:repository:DeleteRepositoryResponse' :: DeleteRepositoryResponse -> Maybe Repository
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Repository
repository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus