{-# 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.DeletePackageVersions
-- 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 one or more versions of a package. A deleted package version
-- cannot be restored in your repository. If you want to remove a package
-- version from your repository and be able to restore it later, set its
-- status to @Archived@. Archived packages cannot be downloaded from a
-- repository and don\'t show up with list package APIs (for example,
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_ListPackageVersions.html ListackageVersions>),
-- but you can restore them using
-- <https://docs.aws.amazon.com/codeartifact/latest/APIReference/API_UpdatePackageVersionsStatus.html UpdatePackageVersionsStatus>.
module Amazonka.CodeArtifact.DeletePackageVersions
  ( -- * Creating a Request
    DeletePackageVersions (..),
    newDeletePackageVersions,

    -- * Request Lenses
    deletePackageVersions_expectedStatus,
    deletePackageVersions_namespace,
    deletePackageVersions_domainOwner,
    deletePackageVersions_domain,
    deletePackageVersions_repository,
    deletePackageVersions_format,
    deletePackageVersions_package,
    deletePackageVersions_versions,

    -- * Destructuring the Response
    DeletePackageVersionsResponse (..),
    newDeletePackageVersionsResponse,

    -- * Response Lenses
    deletePackageVersionsResponse_failedVersions,
    deletePackageVersionsResponse_successfulVersions,
    deletePackageVersionsResponse_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:/ 'newDeletePackageVersions' smart constructor.
data DeletePackageVersions = DeletePackageVersions'
  { -- | The expected status of the package version to delete. Valid values are:
    --
    -- -   @Published@
    --
    -- -   @Unfinished@
    --
    -- -   @Unlisted@
    --
    -- -   @Archived@
    --
    -- -   @Disposed@
    DeletePackageVersions -> Maybe PackageVersionStatus
expectedStatus :: Prelude.Maybe PackageVersionStatus,
    -- | The namespace of the package. The package component that specifies its
    -- namespace depends on its type. For example:
    --
    -- -   The namespace of a Maven package is its @groupId@.
    --
    -- -   The namespace of an npm package is its @scope@.
    --
    -- -   A Python package does not contain a corresponding component, so
    --     Python packages do not have a namespace.
    DeletePackageVersions -> Maybe Text
namespace :: Prelude.Maybe Prelude.Text,
    -- | The 12-digit account number of the AWS account that owns the domain. It
    -- does not include dashes or spaces.
    DeletePackageVersions -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the domain that contains the package to delete.
    DeletePackageVersions -> Text
domain :: Prelude.Text,
    -- | The name of the repository that contains the package versions to delete.
    DeletePackageVersions -> Text
repository :: Prelude.Text,
    -- | The format of the package versions to delete. The valid values are:
    --
    -- -   @npm@
    --
    -- -   @pypi@
    --
    -- -   @maven@
    DeletePackageVersions -> PackageFormat
format :: PackageFormat,
    -- | The name of the package with the versions to delete.
    DeletePackageVersions -> Text
package :: Prelude.Text,
    -- | An array of strings that specify the versions of the package to delete.
    DeletePackageVersions -> [Text]
versions :: [Prelude.Text]
  }
  deriving (DeletePackageVersions -> DeletePackageVersions -> Bool
(DeletePackageVersions -> DeletePackageVersions -> Bool)
-> (DeletePackageVersions -> DeletePackageVersions -> Bool)
-> Eq DeletePackageVersions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePackageVersions -> DeletePackageVersions -> Bool
$c/= :: DeletePackageVersions -> DeletePackageVersions -> Bool
== :: DeletePackageVersions -> DeletePackageVersions -> Bool
$c== :: DeletePackageVersions -> DeletePackageVersions -> Bool
Prelude.Eq, ReadPrec [DeletePackageVersions]
ReadPrec DeletePackageVersions
Int -> ReadS DeletePackageVersions
ReadS [DeletePackageVersions]
(Int -> ReadS DeletePackageVersions)
-> ReadS [DeletePackageVersions]
-> ReadPrec DeletePackageVersions
-> ReadPrec [DeletePackageVersions]
-> Read DeletePackageVersions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePackageVersions]
$creadListPrec :: ReadPrec [DeletePackageVersions]
readPrec :: ReadPrec DeletePackageVersions
$creadPrec :: ReadPrec DeletePackageVersions
readList :: ReadS [DeletePackageVersions]
$creadList :: ReadS [DeletePackageVersions]
readsPrec :: Int -> ReadS DeletePackageVersions
$creadsPrec :: Int -> ReadS DeletePackageVersions
Prelude.Read, Int -> DeletePackageVersions -> ShowS
[DeletePackageVersions] -> ShowS
DeletePackageVersions -> String
(Int -> DeletePackageVersions -> ShowS)
-> (DeletePackageVersions -> String)
-> ([DeletePackageVersions] -> ShowS)
-> Show DeletePackageVersions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePackageVersions] -> ShowS
$cshowList :: [DeletePackageVersions] -> ShowS
show :: DeletePackageVersions -> String
$cshow :: DeletePackageVersions -> String
showsPrec :: Int -> DeletePackageVersions -> ShowS
$cshowsPrec :: Int -> DeletePackageVersions -> ShowS
Prelude.Show, (forall x. DeletePackageVersions -> Rep DeletePackageVersions x)
-> (forall x. Rep DeletePackageVersions x -> DeletePackageVersions)
-> Generic DeletePackageVersions
forall x. Rep DeletePackageVersions x -> DeletePackageVersions
forall x. DeletePackageVersions -> Rep DeletePackageVersions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePackageVersions x -> DeletePackageVersions
$cfrom :: forall x. DeletePackageVersions -> Rep DeletePackageVersions x
Prelude.Generic)

-- |
-- Create a value of 'DeletePackageVersions' 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:
--
-- 'expectedStatus', 'deletePackageVersions_expectedStatus' - The expected status of the package version to delete. Valid values are:
--
-- -   @Published@
--
-- -   @Unfinished@
--
-- -   @Unlisted@
--
-- -   @Archived@
--
-- -   @Disposed@
--
-- 'namespace', 'deletePackageVersions_namespace' - The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
--
-- 'domainOwner', 'deletePackageVersions_domainOwner' - The 12-digit account number of the AWS account that owns the domain. It
-- does not include dashes or spaces.
--
-- 'domain', 'deletePackageVersions_domain' - The name of the domain that contains the package to delete.
--
-- 'repository', 'deletePackageVersions_repository' - The name of the repository that contains the package versions to delete.
--
-- 'format', 'deletePackageVersions_format' - The format of the package versions to delete. The valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
--
-- 'package', 'deletePackageVersions_package' - The name of the package with the versions to delete.
--
-- 'versions', 'deletePackageVersions_versions' - An array of strings that specify the versions of the package to delete.
newDeletePackageVersions ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'format'
  PackageFormat ->
  -- | 'package'
  Prelude.Text ->
  DeletePackageVersions
newDeletePackageVersions :: Text -> Text -> PackageFormat -> Text -> DeletePackageVersions
newDeletePackageVersions
  Text
pDomain_
  Text
pRepository_
  PackageFormat
pFormat_
  Text
pPackage_ =
    DeletePackageVersions' :: Maybe PackageVersionStatus
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> PackageFormat
-> Text
-> [Text]
-> DeletePackageVersions
DeletePackageVersions'
      { $sel:expectedStatus:DeletePackageVersions' :: Maybe PackageVersionStatus
expectedStatus =
          Maybe PackageVersionStatus
forall a. Maybe a
Prelude.Nothing,
        $sel:namespace:DeletePackageVersions' :: Maybe Text
namespace = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:domainOwner:DeletePackageVersions' :: Maybe Text
domainOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:domain:DeletePackageVersions' :: Text
domain = Text
pDomain_,
        $sel:repository:DeletePackageVersions' :: Text
repository = Text
pRepository_,
        $sel:format:DeletePackageVersions' :: PackageFormat
format = PackageFormat
pFormat_,
        $sel:package:DeletePackageVersions' :: Text
package = Text
pPackage_,
        $sel:versions:DeletePackageVersions' :: [Text]
versions = [Text]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The expected status of the package version to delete. Valid values are:
--
-- -   @Published@
--
-- -   @Unfinished@
--
-- -   @Unlisted@
--
-- -   @Archived@
--
-- -   @Disposed@
deletePackageVersions_expectedStatus :: Lens.Lens' DeletePackageVersions (Prelude.Maybe PackageVersionStatus)
deletePackageVersions_expectedStatus :: (Maybe PackageVersionStatus -> f (Maybe PackageVersionStatus))
-> DeletePackageVersions -> f DeletePackageVersions
deletePackageVersions_expectedStatus = (DeletePackageVersions -> Maybe PackageVersionStatus)
-> (DeletePackageVersions
    -> Maybe PackageVersionStatus -> DeletePackageVersions)
-> Lens
     DeletePackageVersions
     DeletePackageVersions
     (Maybe PackageVersionStatus)
     (Maybe PackageVersionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersions' {Maybe PackageVersionStatus
expectedStatus :: Maybe PackageVersionStatus
$sel:expectedStatus:DeletePackageVersions' :: DeletePackageVersions -> Maybe PackageVersionStatus
expectedStatus} -> Maybe PackageVersionStatus
expectedStatus) (\s :: DeletePackageVersions
s@DeletePackageVersions' {} Maybe PackageVersionStatus
a -> DeletePackageVersions
s {$sel:expectedStatus:DeletePackageVersions' :: Maybe PackageVersionStatus
expectedStatus = Maybe PackageVersionStatus
a} :: DeletePackageVersions)

-- | The namespace of the package. The package component that specifies its
-- namespace depends on its type. For example:
--
-- -   The namespace of a Maven package is its @groupId@.
--
-- -   The namespace of an npm package is its @scope@.
--
-- -   A Python package does not contain a corresponding component, so
--     Python packages do not have a namespace.
deletePackageVersions_namespace :: Lens.Lens' DeletePackageVersions (Prelude.Maybe Prelude.Text)
deletePackageVersions_namespace :: (Maybe Text -> f (Maybe Text))
-> DeletePackageVersions -> f DeletePackageVersions
deletePackageVersions_namespace = (DeletePackageVersions -> Maybe Text)
-> (DeletePackageVersions -> Maybe Text -> DeletePackageVersions)
-> Lens
     DeletePackageVersions
     DeletePackageVersions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersions' {Maybe Text
namespace :: Maybe Text
$sel:namespace:DeletePackageVersions' :: DeletePackageVersions -> Maybe Text
namespace} -> Maybe Text
namespace) (\s :: DeletePackageVersions
s@DeletePackageVersions' {} Maybe Text
a -> DeletePackageVersions
s {$sel:namespace:DeletePackageVersions' :: Maybe Text
namespace = Maybe Text
a} :: DeletePackageVersions)

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

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

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

-- | The format of the package versions to delete. The valid values are:
--
-- -   @npm@
--
-- -   @pypi@
--
-- -   @maven@
deletePackageVersions_format :: Lens.Lens' DeletePackageVersions PackageFormat
deletePackageVersions_format :: (PackageFormat -> f PackageFormat)
-> DeletePackageVersions -> f DeletePackageVersions
deletePackageVersions_format = (DeletePackageVersions -> PackageFormat)
-> (DeletePackageVersions
    -> PackageFormat -> DeletePackageVersions)
-> Lens
     DeletePackageVersions
     DeletePackageVersions
     PackageFormat
     PackageFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersions' {PackageFormat
format :: PackageFormat
$sel:format:DeletePackageVersions' :: DeletePackageVersions -> PackageFormat
format} -> PackageFormat
format) (\s :: DeletePackageVersions
s@DeletePackageVersions' {} PackageFormat
a -> DeletePackageVersions
s {$sel:format:DeletePackageVersions' :: PackageFormat
format = PackageFormat
a} :: DeletePackageVersions)

-- | The name of the package with the versions to delete.
deletePackageVersions_package :: Lens.Lens' DeletePackageVersions Prelude.Text
deletePackageVersions_package :: (Text -> f Text)
-> DeletePackageVersions -> f DeletePackageVersions
deletePackageVersions_package = (DeletePackageVersions -> Text)
-> (DeletePackageVersions -> Text -> DeletePackageVersions)
-> Lens DeletePackageVersions DeletePackageVersions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersions' {Text
package :: Text
$sel:package:DeletePackageVersions' :: DeletePackageVersions -> Text
package} -> Text
package) (\s :: DeletePackageVersions
s@DeletePackageVersions' {} Text
a -> DeletePackageVersions
s {$sel:package:DeletePackageVersions' :: Text
package = Text
a} :: DeletePackageVersions)

-- | An array of strings that specify the versions of the package to delete.
deletePackageVersions_versions :: Lens.Lens' DeletePackageVersions [Prelude.Text]
deletePackageVersions_versions :: ([Text] -> f [Text])
-> DeletePackageVersions -> f DeletePackageVersions
deletePackageVersions_versions = (DeletePackageVersions -> [Text])
-> (DeletePackageVersions -> [Text] -> DeletePackageVersions)
-> Lens DeletePackageVersions DeletePackageVersions [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersions' {[Text]
versions :: [Text]
$sel:versions:DeletePackageVersions' :: DeletePackageVersions -> [Text]
versions} -> [Text]
versions) (\s :: DeletePackageVersions
s@DeletePackageVersions' {} [Text]
a -> DeletePackageVersions
s {$sel:versions:DeletePackageVersions' :: [Text]
versions = [Text]
a} :: DeletePackageVersions) (([Text] -> f [Text])
 -> DeletePackageVersions -> f DeletePackageVersions)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeletePackageVersions
-> f DeletePackageVersions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DeletePackageVersions where
  type
    AWSResponse DeletePackageVersions =
      DeletePackageVersionsResponse
  request :: DeletePackageVersions -> Request DeletePackageVersions
request = Service -> DeletePackageVersions -> Request DeletePackageVersions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePackageVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePackageVersions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeletePackageVersions))
-> Logger
-> Service
-> Proxy DeletePackageVersions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePackageVersions)))
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 (HashMap Text PackageVersionError)
-> Maybe (HashMap Text SuccessfulPackageVersionInfo)
-> Int
-> DeletePackageVersionsResponse
DeletePackageVersionsResponse'
            (Maybe (HashMap Text PackageVersionError)
 -> Maybe (HashMap Text SuccessfulPackageVersionInfo)
 -> Int
 -> DeletePackageVersionsResponse)
-> Either String (Maybe (HashMap Text PackageVersionError))
-> Either
     String
     (Maybe (HashMap Text SuccessfulPackageVersionInfo)
      -> Int -> DeletePackageVersionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Either String (Maybe (Maybe (HashMap Text PackageVersionError)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"failedVersions" Either String (Maybe (Maybe (HashMap Text PackageVersionError)))
-> Maybe (HashMap Text PackageVersionError)
-> Either String (Maybe (HashMap Text PackageVersionError))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text PackageVersionError)
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe (HashMap Text SuccessfulPackageVersionInfo)
   -> Int -> DeletePackageVersionsResponse)
-> Either
     String (Maybe (HashMap Text SuccessfulPackageVersionInfo))
-> Either String (Int -> DeletePackageVersionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text
-> Either
     String (Maybe (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"successfulVersions"
                            Either
  String (Maybe (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
-> Maybe (HashMap Text SuccessfulPackageVersionInfo)
-> Either
     String (Maybe (HashMap Text SuccessfulPackageVersionInfo))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text SuccessfulPackageVersionInfo)
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DeletePackageVersionsResponse)
-> Either String Int -> Either String DeletePackageVersionsResponse
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 DeletePackageVersions

instance Prelude.NFData DeletePackageVersions

instance Core.ToHeaders DeletePackageVersions where
  toHeaders :: DeletePackageVersions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePackageVersions -> 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.ToJSON DeletePackageVersions where
  toJSON :: DeletePackageVersions -> Value
toJSON DeletePackageVersions' {[Text]
Maybe Text
Maybe PackageVersionStatus
Text
PackageFormat
versions :: [Text]
package :: Text
format :: PackageFormat
repository :: Text
domain :: Text
domainOwner :: Maybe Text
namespace :: Maybe Text
expectedStatus :: Maybe PackageVersionStatus
$sel:versions:DeletePackageVersions' :: DeletePackageVersions -> [Text]
$sel:package:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:format:DeletePackageVersions' :: DeletePackageVersions -> PackageFormat
$sel:repository:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:domain:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:domainOwner:DeletePackageVersions' :: DeletePackageVersions -> Maybe Text
$sel:namespace:DeletePackageVersions' :: DeletePackageVersions -> Maybe Text
$sel:expectedStatus:DeletePackageVersions' :: DeletePackageVersions -> Maybe PackageVersionStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"expectedStatus" Text -> PackageVersionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (PackageVersionStatus -> Pair)
-> Maybe PackageVersionStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PackageVersionStatus
expectedStatus,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"versions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
versions)
          ]
      )

instance Core.ToPath DeletePackageVersions where
  toPath :: DeletePackageVersions -> ByteString
toPath = ByteString -> DeletePackageVersions -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/package/versions/delete"

instance Core.ToQuery DeletePackageVersions where
  toQuery :: DeletePackageVersions -> QueryString
toQuery DeletePackageVersions' {[Text]
Maybe Text
Maybe PackageVersionStatus
Text
PackageFormat
versions :: [Text]
package :: Text
format :: PackageFormat
repository :: Text
domain :: Text
domainOwner :: Maybe Text
namespace :: Maybe Text
expectedStatus :: Maybe PackageVersionStatus
$sel:versions:DeletePackageVersions' :: DeletePackageVersions -> [Text]
$sel:package:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:format:DeletePackageVersions' :: DeletePackageVersions -> PackageFormat
$sel:repository:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:domain:DeletePackageVersions' :: DeletePackageVersions -> Text
$sel:domainOwner:DeletePackageVersions' :: DeletePackageVersions -> Maybe Text
$sel:namespace:DeletePackageVersions' :: DeletePackageVersions -> Maybe Text
$sel:expectedStatus:DeletePackageVersions' :: DeletePackageVersions -> Maybe PackageVersionStatus
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"namespace" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
namespace,
        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,
        ByteString
"format" ByteString -> PackageFormat -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: PackageFormat
format,
        ByteString
"package" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
package
      ]

-- | /See:/ 'newDeletePackageVersionsResponse' smart constructor.
data DeletePackageVersionsResponse = DeletePackageVersionsResponse'
  { -- | A @PackageVersionError@ object that contains a map of errors codes for
    -- the deleted package that failed. The possible error codes are:
    --
    -- -   @ALREADY_EXISTS@
    --
    -- -   @MISMATCHED_REVISION@
    --
    -- -   @MISMATCHED_STATUS@
    --
    -- -   @NOT_ALLOWED@
    --
    -- -   @NOT_FOUND@
    --
    -- -   @SKIPPED@
    DeletePackageVersionsResponse
-> Maybe (HashMap Text PackageVersionError)
failedVersions :: Prelude.Maybe (Prelude.HashMap Prelude.Text PackageVersionError),
    -- | A list of the package versions that were successfully deleted.
    DeletePackageVersionsResponse
-> Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions :: Prelude.Maybe (Prelude.HashMap Prelude.Text SuccessfulPackageVersionInfo),
    -- | The response's http status code.
    DeletePackageVersionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeletePackageVersionsResponse
-> DeletePackageVersionsResponse -> Bool
(DeletePackageVersionsResponse
 -> DeletePackageVersionsResponse -> Bool)
-> (DeletePackageVersionsResponse
    -> DeletePackageVersionsResponse -> Bool)
-> Eq DeletePackageVersionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePackageVersionsResponse
-> DeletePackageVersionsResponse -> Bool
$c/= :: DeletePackageVersionsResponse
-> DeletePackageVersionsResponse -> Bool
== :: DeletePackageVersionsResponse
-> DeletePackageVersionsResponse -> Bool
$c== :: DeletePackageVersionsResponse
-> DeletePackageVersionsResponse -> Bool
Prelude.Eq, ReadPrec [DeletePackageVersionsResponse]
ReadPrec DeletePackageVersionsResponse
Int -> ReadS DeletePackageVersionsResponse
ReadS [DeletePackageVersionsResponse]
(Int -> ReadS DeletePackageVersionsResponse)
-> ReadS [DeletePackageVersionsResponse]
-> ReadPrec DeletePackageVersionsResponse
-> ReadPrec [DeletePackageVersionsResponse]
-> Read DeletePackageVersionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePackageVersionsResponse]
$creadListPrec :: ReadPrec [DeletePackageVersionsResponse]
readPrec :: ReadPrec DeletePackageVersionsResponse
$creadPrec :: ReadPrec DeletePackageVersionsResponse
readList :: ReadS [DeletePackageVersionsResponse]
$creadList :: ReadS [DeletePackageVersionsResponse]
readsPrec :: Int -> ReadS DeletePackageVersionsResponse
$creadsPrec :: Int -> ReadS DeletePackageVersionsResponse
Prelude.Read, Int -> DeletePackageVersionsResponse -> ShowS
[DeletePackageVersionsResponse] -> ShowS
DeletePackageVersionsResponse -> String
(Int -> DeletePackageVersionsResponse -> ShowS)
-> (DeletePackageVersionsResponse -> String)
-> ([DeletePackageVersionsResponse] -> ShowS)
-> Show DeletePackageVersionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePackageVersionsResponse] -> ShowS
$cshowList :: [DeletePackageVersionsResponse] -> ShowS
show :: DeletePackageVersionsResponse -> String
$cshow :: DeletePackageVersionsResponse -> String
showsPrec :: Int -> DeletePackageVersionsResponse -> ShowS
$cshowsPrec :: Int -> DeletePackageVersionsResponse -> ShowS
Prelude.Show, (forall x.
 DeletePackageVersionsResponse
 -> Rep DeletePackageVersionsResponse x)
-> (forall x.
    Rep DeletePackageVersionsResponse x
    -> DeletePackageVersionsResponse)
-> Generic DeletePackageVersionsResponse
forall x.
Rep DeletePackageVersionsResponse x
-> DeletePackageVersionsResponse
forall x.
DeletePackageVersionsResponse
-> Rep DeletePackageVersionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeletePackageVersionsResponse x
-> DeletePackageVersionsResponse
$cfrom :: forall x.
DeletePackageVersionsResponse
-> Rep DeletePackageVersionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeletePackageVersionsResponse' 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:
--
-- 'failedVersions', 'deletePackageVersionsResponse_failedVersions' - A @PackageVersionError@ object that contains a map of errors codes for
-- the deleted package that failed. The possible error codes are:
--
-- -   @ALREADY_EXISTS@
--
-- -   @MISMATCHED_REVISION@
--
-- -   @MISMATCHED_STATUS@
--
-- -   @NOT_ALLOWED@
--
-- -   @NOT_FOUND@
--
-- -   @SKIPPED@
--
-- 'successfulVersions', 'deletePackageVersionsResponse_successfulVersions' - A list of the package versions that were successfully deleted.
--
-- 'httpStatus', 'deletePackageVersionsResponse_httpStatus' - The response's http status code.
newDeletePackageVersionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeletePackageVersionsResponse
newDeletePackageVersionsResponse :: Int -> DeletePackageVersionsResponse
newDeletePackageVersionsResponse Int
pHttpStatus_ =
  DeletePackageVersionsResponse' :: Maybe (HashMap Text PackageVersionError)
-> Maybe (HashMap Text SuccessfulPackageVersionInfo)
-> Int
-> DeletePackageVersionsResponse
DeletePackageVersionsResponse'
    { $sel:failedVersions:DeletePackageVersionsResponse' :: Maybe (HashMap Text PackageVersionError)
failedVersions =
        Maybe (HashMap Text PackageVersionError)
forall a. Maybe a
Prelude.Nothing,
      $sel:successfulVersions:DeletePackageVersionsResponse' :: Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions = Maybe (HashMap Text SuccessfulPackageVersionInfo)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeletePackageVersionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @PackageVersionError@ object that contains a map of errors codes for
-- the deleted package that failed. The possible error codes are:
--
-- -   @ALREADY_EXISTS@
--
-- -   @MISMATCHED_REVISION@
--
-- -   @MISMATCHED_STATUS@
--
-- -   @NOT_ALLOWED@
--
-- -   @NOT_FOUND@
--
-- -   @SKIPPED@
deletePackageVersionsResponse_failedVersions :: Lens.Lens' DeletePackageVersionsResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text PackageVersionError))
deletePackageVersionsResponse_failedVersions :: (Maybe (HashMap Text PackageVersionError)
 -> f (Maybe (HashMap Text PackageVersionError)))
-> DeletePackageVersionsResponse -> f DeletePackageVersionsResponse
deletePackageVersionsResponse_failedVersions = (DeletePackageVersionsResponse
 -> Maybe (HashMap Text PackageVersionError))
-> (DeletePackageVersionsResponse
    -> Maybe (HashMap Text PackageVersionError)
    -> DeletePackageVersionsResponse)
-> Lens
     DeletePackageVersionsResponse
     DeletePackageVersionsResponse
     (Maybe (HashMap Text PackageVersionError))
     (Maybe (HashMap Text PackageVersionError))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersionsResponse' {Maybe (HashMap Text PackageVersionError)
failedVersions :: Maybe (HashMap Text PackageVersionError)
$sel:failedVersions:DeletePackageVersionsResponse' :: DeletePackageVersionsResponse
-> Maybe (HashMap Text PackageVersionError)
failedVersions} -> Maybe (HashMap Text PackageVersionError)
failedVersions) (\s :: DeletePackageVersionsResponse
s@DeletePackageVersionsResponse' {} Maybe (HashMap Text PackageVersionError)
a -> DeletePackageVersionsResponse
s {$sel:failedVersions:DeletePackageVersionsResponse' :: Maybe (HashMap Text PackageVersionError)
failedVersions = Maybe (HashMap Text PackageVersionError)
a} :: DeletePackageVersionsResponse) ((Maybe (HashMap Text PackageVersionError)
  -> f (Maybe (HashMap Text PackageVersionError)))
 -> DeletePackageVersionsResponse
 -> f DeletePackageVersionsResponse)
-> ((Maybe (HashMap Text PackageVersionError)
     -> f (Maybe (HashMap Text PackageVersionError)))
    -> Maybe (HashMap Text PackageVersionError)
    -> f (Maybe (HashMap Text PackageVersionError)))
-> (Maybe (HashMap Text PackageVersionError)
    -> f (Maybe (HashMap Text PackageVersionError)))
-> DeletePackageVersionsResponse
-> f DeletePackageVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
-> Iso
     (Maybe (HashMap Text PackageVersionError))
     (Maybe (HashMap Text PackageVersionError))
     (Maybe (HashMap Text PackageVersionError))
     (Maybe (HashMap Text PackageVersionError))
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
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
  (HashMap Text PackageVersionError)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of the package versions that were successfully deleted.
deletePackageVersionsResponse_successfulVersions :: Lens.Lens' DeletePackageVersionsResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text SuccessfulPackageVersionInfo))
deletePackageVersionsResponse_successfulVersions :: (Maybe (HashMap Text SuccessfulPackageVersionInfo)
 -> f (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
-> DeletePackageVersionsResponse -> f DeletePackageVersionsResponse
deletePackageVersionsResponse_successfulVersions = (DeletePackageVersionsResponse
 -> Maybe (HashMap Text SuccessfulPackageVersionInfo))
-> (DeletePackageVersionsResponse
    -> Maybe (HashMap Text SuccessfulPackageVersionInfo)
    -> DeletePackageVersionsResponse)
-> Lens
     DeletePackageVersionsResponse
     DeletePackageVersionsResponse
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePackageVersionsResponse' {Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions :: Maybe (HashMap Text SuccessfulPackageVersionInfo)
$sel:successfulVersions:DeletePackageVersionsResponse' :: DeletePackageVersionsResponse
-> Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions} -> Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions) (\s :: DeletePackageVersionsResponse
s@DeletePackageVersionsResponse' {} Maybe (HashMap Text SuccessfulPackageVersionInfo)
a -> DeletePackageVersionsResponse
s {$sel:successfulVersions:DeletePackageVersionsResponse' :: Maybe (HashMap Text SuccessfulPackageVersionInfo)
successfulVersions = Maybe (HashMap Text SuccessfulPackageVersionInfo)
a} :: DeletePackageVersionsResponse) ((Maybe (HashMap Text SuccessfulPackageVersionInfo)
  -> f (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
 -> DeletePackageVersionsResponse
 -> f DeletePackageVersionsResponse)
-> ((Maybe (HashMap Text SuccessfulPackageVersionInfo)
     -> f (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
    -> Maybe (HashMap Text SuccessfulPackageVersionInfo)
    -> f (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
-> (Maybe (HashMap Text SuccessfulPackageVersionInfo)
    -> f (Maybe (HashMap Text SuccessfulPackageVersionInfo)))
-> DeletePackageVersionsResponse
-> f DeletePackageVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
-> Iso
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
     (Maybe (HashMap Text SuccessfulPackageVersionInfo))
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
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
  (HashMap Text SuccessfulPackageVersionInfo)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeletePackageVersionsResponse