{-# 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.CodeArtifact.DeleteRepository
-- 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 a repository.
module Amazonka.CodeArtifact.DeleteRepository
  ( -- * Creating a Request
    DeleteRepository (..),
    newDeleteRepository,

    -- * Request Lenses
    deleteRepository_domainOwner,
    deleteRepository_domain,
    deleteRepository_repository,

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

    -- * Response Lenses
    deleteRepositoryResponse_repository,
    deleteRepositoryResponse_httpStatus,
  )
where

import Amazonka.CodeArtifact.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:/ 'newDeleteRepository' smart constructor.
data DeleteRepository = DeleteRepository'
  { -- | The 12-digit account number of the AWS account that owns the domain. It
    -- does not include dashes or spaces.
    DeleteRepository -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the repository to delete.
    DeleteRepository -> Text
domain :: Prelude.Text,
    -- | The name of the repository to delete.
    DeleteRepository -> Text
repository :: Prelude.Text
  }
  deriving (DeleteRepository -> DeleteRepository -> Bool
(DeleteRepository -> DeleteRepository -> Bool)
-> (DeleteRepository -> DeleteRepository -> Bool)
-> Eq DeleteRepository
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]
(Int -> ReadS DeleteRepository)
-> ReadS [DeleteRepository]
-> ReadPrec DeleteRepository
-> ReadPrec [DeleteRepository]
-> Read 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
(Int -> DeleteRepository -> ShowS)
-> (DeleteRepository -> String)
-> ([DeleteRepository] -> ShowS)
-> Show DeleteRepository
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. DeleteRepository -> Rep DeleteRepository x)
-> (forall x. Rep DeleteRepository x -> DeleteRepository)
-> Generic DeleteRepository
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:
--
-- 'domainOwner', 'deleteRepository_domainOwner' - The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
--
-- 'domain', 'deleteRepository_domain' - The name of the domain that contains the repository to delete.
--
-- 'repository', 'deleteRepository_repository' - The name of the repository to delete.
newDeleteRepository ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  DeleteRepository
newDeleteRepository :: Text -> Text -> DeleteRepository
newDeleteRepository Text
pDomain_ Text
pRepository_ =
  DeleteRepository' :: Maybe Text -> Text -> Text -> DeleteRepository
DeleteRepository'
    { $sel:domainOwner:DeleteRepository' :: Maybe Text
domainOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:DeleteRepository' :: Text
domain = Text
pDomain_,
      $sel:repository:DeleteRepository' :: Text
repository = Text
pRepository_
    }

-- | The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
deleteRepository_domainOwner :: Lens.Lens' DeleteRepository (Prelude.Maybe Prelude.Text)
deleteRepository_domainOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteRepository -> f DeleteRepository
deleteRepository_domainOwner = (DeleteRepository -> Maybe Text)
-> (DeleteRepository -> Maybe Text -> DeleteRepository)
-> Lens DeleteRepository DeleteRepository (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepository' {Maybe Text
domainOwner :: Maybe Text
$sel:domainOwner:DeleteRepository' :: DeleteRepository -> Maybe Text
domainOwner} -> Maybe Text
domainOwner) (\s :: DeleteRepository
s@DeleteRepository' {} Maybe Text
a -> DeleteRepository
s {$sel:domainOwner:DeleteRepository' :: Maybe Text
domainOwner = Maybe Text
a} :: DeleteRepository)

-- | The name of the domain that contains the repository to delete.
deleteRepository_domain :: Lens.Lens' DeleteRepository Prelude.Text
deleteRepository_domain :: (Text -> f Text) -> DeleteRepository -> f DeleteRepository
deleteRepository_domain = (DeleteRepository -> Text)
-> (DeleteRepository -> Text -> DeleteRepository)
-> Lens DeleteRepository DeleteRepository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepository' {Text
domain :: Text
$sel:domain:DeleteRepository' :: DeleteRepository -> Text
domain} -> Text
domain) (\s :: DeleteRepository
s@DeleteRepository' {} Text
a -> DeleteRepository
s {$sel:domain:DeleteRepository' :: Text
domain = Text
a} :: DeleteRepository)

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

instance Core.AWSRequest DeleteRepository where
  type
    AWSResponse DeleteRepository =
      DeleteRepositoryResponse
  request :: DeleteRepository -> Request DeleteRepository
request = Service -> DeleteRepository -> Request DeleteRepository
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteRepository
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteRepository)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteRepository))
-> Logger
-> Service
-> Proxy DeleteRepository
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteRepository)))
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 RepositoryDescription -> Int -> DeleteRepositoryResponse
DeleteRepositoryResponse'
            (Maybe RepositoryDescription -> Int -> DeleteRepositoryResponse)
-> Either String (Maybe RepositoryDescription)
-> Either String (Int -> DeleteRepositoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RepositoryDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"repository")
            Either String (Int -> DeleteRepositoryResponse)
-> Either String Int -> Either String DeleteRepositoryResponse
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 DeleteRepository

instance Prelude.NFData DeleteRepository

instance Core.ToHeaders DeleteRepository where
  toHeaders :: DeleteRepository -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteRepository -> 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 DeleteRepository where
  toPath :: DeleteRepository -> ByteString
toPath = ByteString -> DeleteRepository -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/repository"

instance Core.ToQuery DeleteRepository where
  toQuery :: DeleteRepository -> QueryString
toQuery DeleteRepository' {Maybe Text
Text
repository :: Text
domain :: Text
domainOwner :: Maybe Text
$sel:repository:DeleteRepository' :: DeleteRepository -> Text
$sel:domain:DeleteRepository' :: DeleteRepository -> Text
$sel:domainOwner:DeleteRepository' :: DeleteRepository -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"domain-owner" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
domainOwner,
        ByteString
"domain" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
domain,
        ByteString
"repository" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
repository
      ]

-- | /See:/ 'newDeleteRepositoryResponse' smart constructor.
data DeleteRepositoryResponse = DeleteRepositoryResponse'
  { -- | Information about the deleted repository after processing the request.
    DeleteRepositoryResponse -> Maybe RepositoryDescription
repository :: Prelude.Maybe RepositoryDescription,
    -- | The response's http status code.
    DeleteRepositoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteRepositoryResponse -> DeleteRepositoryResponse -> Bool
(DeleteRepositoryResponse -> DeleteRepositoryResponse -> Bool)
-> (DeleteRepositoryResponse -> DeleteRepositoryResponse -> Bool)
-> Eq DeleteRepositoryResponse
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]
(Int -> ReadS DeleteRepositoryResponse)
-> ReadS [DeleteRepositoryResponse]
-> ReadPrec DeleteRepositoryResponse
-> ReadPrec [DeleteRepositoryResponse]
-> Read 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
(Int -> DeleteRepositoryResponse -> ShowS)
-> (DeleteRepositoryResponse -> String)
-> ([DeleteRepositoryResponse] -> ShowS)
-> Show DeleteRepositoryResponse
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.
 DeleteRepositoryResponse -> Rep DeleteRepositoryResponse x)
-> (forall x.
    Rep DeleteRepositoryResponse x -> DeleteRepositoryResponse)
-> Generic DeleteRepositoryResponse
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' - Information about the deleted repository after processing the request.
--
-- 'httpStatus', 'deleteRepositoryResponse_httpStatus' - The response's http status code.
newDeleteRepositoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRepositoryResponse
newDeleteRepositoryResponse :: Int -> DeleteRepositoryResponse
newDeleteRepositoryResponse Int
pHttpStatus_ =
  DeleteRepositoryResponse' :: Maybe RepositoryDescription -> Int -> DeleteRepositoryResponse
DeleteRepositoryResponse'
    { $sel:repository:DeleteRepositoryResponse' :: Maybe RepositoryDescription
repository =
        Maybe RepositoryDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteRepositoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deleted repository after processing the request.
deleteRepositoryResponse_repository :: Lens.Lens' DeleteRepositoryResponse (Prelude.Maybe RepositoryDescription)
deleteRepositoryResponse_repository :: (Maybe RepositoryDescription -> f (Maybe RepositoryDescription))
-> DeleteRepositoryResponse -> f DeleteRepositoryResponse
deleteRepositoryResponse_repository = (DeleteRepositoryResponse -> Maybe RepositoryDescription)
-> (DeleteRepositoryResponse
    -> Maybe RepositoryDescription -> DeleteRepositoryResponse)
-> Lens
     DeleteRepositoryResponse
     DeleteRepositoryResponse
     (Maybe RepositoryDescription)
     (Maybe RepositoryDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRepositoryResponse' {Maybe RepositoryDescription
repository :: Maybe RepositoryDescription
$sel:repository:DeleteRepositoryResponse' :: DeleteRepositoryResponse -> Maybe RepositoryDescription
repository} -> Maybe RepositoryDescription
repository) (\s :: DeleteRepositoryResponse
s@DeleteRepositoryResponse' {} Maybe RepositoryDescription
a -> DeleteRepositoryResponse
s {$sel:repository:DeleteRepositoryResponse' :: Maybe RepositoryDescription
repository = Maybe RepositoryDescription
a} :: DeleteRepositoryResponse)

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