{-# 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.CloudWatch.DeleteDashboards
-- 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 all dashboards that you specify. You can specify up to 100
-- dashboards to delete. If there is an error during this call, no
-- dashboards are deleted.
module Amazonka.CloudWatch.DeleteDashboards
  ( -- * Creating a Request
    DeleteDashboards (..),
    newDeleteDashboards,

    -- * Request Lenses
    deleteDashboards_dashboardNames,

    -- * Destructuring the Response
    DeleteDashboardsResponse (..),
    newDeleteDashboardsResponse,

    -- * Response Lenses
    deleteDashboardsResponse_httpStatus,
  )
where

import Amazonka.CloudWatch.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:/ 'newDeleteDashboards' smart constructor.
data DeleteDashboards = DeleteDashboards'
  { -- | The dashboards to be deleted. This parameter is required.
    DeleteDashboards -> [Text]
dashboardNames :: [Prelude.Text]
  }
  deriving (DeleteDashboards -> DeleteDashboards -> Bool
(DeleteDashboards -> DeleteDashboards -> Bool)
-> (DeleteDashboards -> DeleteDashboards -> Bool)
-> Eq DeleteDashboards
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDashboards -> DeleteDashboards -> Bool
$c/= :: DeleteDashboards -> DeleteDashboards -> Bool
== :: DeleteDashboards -> DeleteDashboards -> Bool
$c== :: DeleteDashboards -> DeleteDashboards -> Bool
Prelude.Eq, ReadPrec [DeleteDashboards]
ReadPrec DeleteDashboards
Int -> ReadS DeleteDashboards
ReadS [DeleteDashboards]
(Int -> ReadS DeleteDashboards)
-> ReadS [DeleteDashboards]
-> ReadPrec DeleteDashboards
-> ReadPrec [DeleteDashboards]
-> Read DeleteDashboards
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDashboards]
$creadListPrec :: ReadPrec [DeleteDashboards]
readPrec :: ReadPrec DeleteDashboards
$creadPrec :: ReadPrec DeleteDashboards
readList :: ReadS [DeleteDashboards]
$creadList :: ReadS [DeleteDashboards]
readsPrec :: Int -> ReadS DeleteDashboards
$creadsPrec :: Int -> ReadS DeleteDashboards
Prelude.Read, Int -> DeleteDashboards -> ShowS
[DeleteDashboards] -> ShowS
DeleteDashboards -> String
(Int -> DeleteDashboards -> ShowS)
-> (DeleteDashboards -> String)
-> ([DeleteDashboards] -> ShowS)
-> Show DeleteDashboards
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDashboards] -> ShowS
$cshowList :: [DeleteDashboards] -> ShowS
show :: DeleteDashboards -> String
$cshow :: DeleteDashboards -> String
showsPrec :: Int -> DeleteDashboards -> ShowS
$cshowsPrec :: Int -> DeleteDashboards -> ShowS
Prelude.Show, (forall x. DeleteDashboards -> Rep DeleteDashboards x)
-> (forall x. Rep DeleteDashboards x -> DeleteDashboards)
-> Generic DeleteDashboards
forall x. Rep DeleteDashboards x -> DeleteDashboards
forall x. DeleteDashboards -> Rep DeleteDashboards x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDashboards x -> DeleteDashboards
$cfrom :: forall x. DeleteDashboards -> Rep DeleteDashboards x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDashboards' 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:
--
-- 'dashboardNames', 'deleteDashboards_dashboardNames' - The dashboards to be deleted. This parameter is required.
newDeleteDashboards ::
  DeleteDashboards
newDeleteDashboards :: DeleteDashboards
newDeleteDashboards =
  DeleteDashboards' :: [Text] -> DeleteDashboards
DeleteDashboards' {$sel:dashboardNames:DeleteDashboards' :: [Text]
dashboardNames = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The dashboards to be deleted. This parameter is required.
deleteDashboards_dashboardNames :: Lens.Lens' DeleteDashboards [Prelude.Text]
deleteDashboards_dashboardNames :: ([Text] -> f [Text]) -> DeleteDashboards -> f DeleteDashboards
deleteDashboards_dashboardNames = (DeleteDashboards -> [Text])
-> (DeleteDashboards -> [Text] -> DeleteDashboards)
-> Lens DeleteDashboards DeleteDashboards [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDashboards' {[Text]
dashboardNames :: [Text]
$sel:dashboardNames:DeleteDashboards' :: DeleteDashboards -> [Text]
dashboardNames} -> [Text]
dashboardNames) (\s :: DeleteDashboards
s@DeleteDashboards' {} [Text]
a -> DeleteDashboards
s {$sel:dashboardNames:DeleteDashboards' :: [Text]
dashboardNames = [Text]
a} :: DeleteDashboards) (([Text] -> f [Text]) -> DeleteDashboards -> f DeleteDashboards)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeleteDashboards
-> f DeleteDashboards
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 DeleteDashboards where
  type
    AWSResponse DeleteDashboards =
      DeleteDashboardsResponse
  request :: DeleteDashboards -> Request DeleteDashboards
request = Service -> DeleteDashboards -> Request DeleteDashboards
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDashboards
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDashboards)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DeleteDashboards))
-> Logger
-> Service
-> Proxy DeleteDashboards
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDashboards)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DeleteDashboardsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> DeleteDashboardsResponse
DeleteDashboardsResponse'
            (Int -> DeleteDashboardsResponse)
-> Either String Int -> Either String DeleteDashboardsResponse
forall (f :: * -> *) a b. Functor 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 DeleteDashboards

instance Prelude.NFData DeleteDashboards

instance Core.ToHeaders DeleteDashboards where
  toHeaders :: DeleteDashboards -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteDashboards -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DeleteDashboards where
  toQuery :: DeleteDashboards -> QueryString
toQuery DeleteDashboards' {[Text]
dashboardNames :: [Text]
$sel:dashboardNames:DeleteDashboards' :: DeleteDashboards -> [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteDashboards" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"DashboardNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Text]
dashboardNames
      ]

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

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

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

instance Prelude.NFData DeleteDashboardsResponse