{-# 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.WorkDocs.DeleteLabels
-- 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 the specified list of labels from a resource.
module Amazonka.WorkDocs.DeleteLabels
  ( -- * Creating a Request
    DeleteLabels (..),
    newDeleteLabels,

    -- * Request Lenses
    deleteLabels_deleteAll,
    deleteLabels_authenticationToken,
    deleteLabels_labels,
    deleteLabels_resourceId,

    -- * Destructuring the Response
    DeleteLabelsResponse (..),
    newDeleteLabelsResponse,

    -- * Response Lenses
    deleteLabelsResponse_httpStatus,
  )
where

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
import Amazonka.WorkDocs.Types

-- | /See:/ 'newDeleteLabels' smart constructor.
data DeleteLabels = DeleteLabels'
  { -- | Flag to request removal of all labels from the specified resource.
    DeleteLabels -> Maybe Bool
deleteAll :: Prelude.Maybe Prelude.Bool,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    DeleteLabels -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | List of labels to delete from the resource.
    DeleteLabels -> Maybe [Text]
labels :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the resource.
    DeleteLabels -> Text
resourceId :: Prelude.Text
  }
  deriving (DeleteLabels -> DeleteLabels -> Bool
(DeleteLabels -> DeleteLabels -> Bool)
-> (DeleteLabels -> DeleteLabels -> Bool) -> Eq DeleteLabels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteLabels -> DeleteLabels -> Bool
$c/= :: DeleteLabels -> DeleteLabels -> Bool
== :: DeleteLabels -> DeleteLabels -> Bool
$c== :: DeleteLabels -> DeleteLabels -> Bool
Prelude.Eq, Int -> DeleteLabels -> ShowS
[DeleteLabels] -> ShowS
DeleteLabels -> String
(Int -> DeleteLabels -> ShowS)
-> (DeleteLabels -> String)
-> ([DeleteLabels] -> ShowS)
-> Show DeleteLabels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteLabels] -> ShowS
$cshowList :: [DeleteLabels] -> ShowS
show :: DeleteLabels -> String
$cshow :: DeleteLabels -> String
showsPrec :: Int -> DeleteLabels -> ShowS
$cshowsPrec :: Int -> DeleteLabels -> ShowS
Prelude.Show, (forall x. DeleteLabels -> Rep DeleteLabels x)
-> (forall x. Rep DeleteLabels x -> DeleteLabels)
-> Generic DeleteLabels
forall x. Rep DeleteLabels x -> DeleteLabels
forall x. DeleteLabels -> Rep DeleteLabels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteLabels x -> DeleteLabels
$cfrom :: forall x. DeleteLabels -> Rep DeleteLabels x
Prelude.Generic)

-- |
-- Create a value of 'DeleteLabels' 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:
--
-- 'deleteAll', 'deleteLabels_deleteAll' - Flag to request removal of all labels from the specified resource.
--
-- 'authenticationToken', 'deleteLabels_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'labels', 'deleteLabels_labels' - List of labels to delete from the resource.
--
-- 'resourceId', 'deleteLabels_resourceId' - The ID of the resource.
newDeleteLabels ::
  -- | 'resourceId'
  Prelude.Text ->
  DeleteLabels
newDeleteLabels :: Text -> DeleteLabels
newDeleteLabels Text
pResourceId_ =
  DeleteLabels' :: Maybe Bool
-> Maybe (Sensitive Text) -> Maybe [Text] -> Text -> DeleteLabels
DeleteLabels'
    { $sel:deleteAll:DeleteLabels' :: Maybe Bool
deleteAll = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationToken:DeleteLabels' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:labels:DeleteLabels' :: Maybe [Text]
labels = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceId:DeleteLabels' :: Text
resourceId = Text
pResourceId_
    }

-- | Flag to request removal of all labels from the specified resource.
deleteLabels_deleteAll :: Lens.Lens' DeleteLabels (Prelude.Maybe Prelude.Bool)
deleteLabels_deleteAll :: (Maybe Bool -> f (Maybe Bool)) -> DeleteLabels -> f DeleteLabels
deleteLabels_deleteAll = (DeleteLabels -> Maybe Bool)
-> (DeleteLabels -> Maybe Bool -> DeleteLabels)
-> Lens DeleteLabels DeleteLabels (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLabels' {Maybe Bool
deleteAll :: Maybe Bool
$sel:deleteAll:DeleteLabels' :: DeleteLabels -> Maybe Bool
deleteAll} -> Maybe Bool
deleteAll) (\s :: DeleteLabels
s@DeleteLabels' {} Maybe Bool
a -> DeleteLabels
s {$sel:deleteAll:DeleteLabels' :: Maybe Bool
deleteAll = Maybe Bool
a} :: DeleteLabels)

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
deleteLabels_authenticationToken :: Lens.Lens' DeleteLabels (Prelude.Maybe Prelude.Text)
deleteLabels_authenticationToken :: (Maybe Text -> f (Maybe Text)) -> DeleteLabels -> f DeleteLabels
deleteLabels_authenticationToken = (DeleteLabels -> Maybe (Sensitive Text))
-> (DeleteLabels -> Maybe (Sensitive Text) -> DeleteLabels)
-> Lens
     DeleteLabels
     DeleteLabels
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLabels' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:DeleteLabels' :: DeleteLabels -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: DeleteLabels
s@DeleteLabels' {} Maybe (Sensitive Text)
a -> DeleteLabels
s {$sel:authenticationToken:DeleteLabels' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: DeleteLabels) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DeleteLabels -> f DeleteLabels)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DeleteLabels
-> f DeleteLabels
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | List of labels to delete from the resource.
deleteLabels_labels :: Lens.Lens' DeleteLabels (Prelude.Maybe [Prelude.Text])
deleteLabels_labels :: (Maybe [Text] -> f (Maybe [Text]))
-> DeleteLabels -> f DeleteLabels
deleteLabels_labels = (DeleteLabels -> Maybe [Text])
-> (DeleteLabels -> Maybe [Text] -> DeleteLabels)
-> Lens DeleteLabels DeleteLabels (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLabels' {Maybe [Text]
labels :: Maybe [Text]
$sel:labels:DeleteLabels' :: DeleteLabels -> Maybe [Text]
labels} -> Maybe [Text]
labels) (\s :: DeleteLabels
s@DeleteLabels' {} Maybe [Text]
a -> DeleteLabels
s {$sel:labels:DeleteLabels' :: Maybe [Text]
labels = Maybe [Text]
a} :: DeleteLabels) ((Maybe [Text] -> f (Maybe [Text]))
 -> DeleteLabels -> f DeleteLabels)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DeleteLabels
-> f DeleteLabels
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the resource.
deleteLabels_resourceId :: Lens.Lens' DeleteLabels Prelude.Text
deleteLabels_resourceId :: (Text -> f Text) -> DeleteLabels -> f DeleteLabels
deleteLabels_resourceId = (DeleteLabels -> Text)
-> (DeleteLabels -> Text -> DeleteLabels)
-> Lens DeleteLabels DeleteLabels Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLabels' {Text
resourceId :: Text
$sel:resourceId:DeleteLabels' :: DeleteLabels -> Text
resourceId} -> Text
resourceId) (\s :: DeleteLabels
s@DeleteLabels' {} Text
a -> DeleteLabels
s {$sel:resourceId:DeleteLabels' :: Text
resourceId = Text
a} :: DeleteLabels)

instance Core.AWSRequest DeleteLabels where
  type AWSResponse DeleteLabels = DeleteLabelsResponse
  request :: DeleteLabels -> Request DeleteLabels
request = Service -> DeleteLabels -> Request DeleteLabels
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteLabels)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteLabels))
-> Logger
-> Service
-> Proxy DeleteLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteLabels)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteLabelsResponse
DeleteLabelsResponse'
            (Int -> DeleteLabelsResponse)
-> Either String Int -> Either String DeleteLabelsResponse
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 DeleteLabels

instance Prelude.NFData DeleteLabels

instance Core.ToHeaders DeleteLabels where
  toHeaders :: DeleteLabels -> ResponseHeaders
toHeaders DeleteLabels' {Maybe Bool
Maybe [Text]
Maybe (Sensitive Text)
Text
resourceId :: Text
labels :: Maybe [Text]
authenticationToken :: Maybe (Sensitive Text)
deleteAll :: Maybe Bool
$sel:resourceId:DeleteLabels' :: DeleteLabels -> Text
$sel:labels:DeleteLabels' :: DeleteLabels -> Maybe [Text]
$sel:authenticationToken:DeleteLabels' :: DeleteLabels -> Maybe (Sensitive Text)
$sel:deleteAll:DeleteLabels' :: DeleteLabels -> Maybe Bool
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe (Sensitive Text)
authenticationToken,
        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 DeleteLabels where
  toPath :: DeleteLabels -> ByteString
toPath DeleteLabels' {Maybe Bool
Maybe [Text]
Maybe (Sensitive Text)
Text
resourceId :: Text
labels :: Maybe [Text]
authenticationToken :: Maybe (Sensitive Text)
deleteAll :: Maybe Bool
$sel:resourceId:DeleteLabels' :: DeleteLabels -> Text
$sel:labels:DeleteLabels' :: DeleteLabels -> Maybe [Text]
$sel:authenticationToken:DeleteLabels' :: DeleteLabels -> Maybe (Sensitive Text)
$sel:deleteAll:DeleteLabels' :: DeleteLabels -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/resources/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId,
        ByteString
"/labels"
      ]

instance Core.ToQuery DeleteLabels where
  toQuery :: DeleteLabels -> QueryString
toQuery DeleteLabels' {Maybe Bool
Maybe [Text]
Maybe (Sensitive Text)
Text
resourceId :: Text
labels :: Maybe [Text]
authenticationToken :: Maybe (Sensitive Text)
deleteAll :: Maybe Bool
$sel:resourceId:DeleteLabels' :: DeleteLabels -> Text
$sel:labels:DeleteLabels' :: DeleteLabels -> Maybe [Text]
$sel:authenticationToken:DeleteLabels' :: DeleteLabels -> Maybe (Sensitive Text)
$sel:deleteAll:DeleteLabels' :: DeleteLabels -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"deleteAll" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
deleteAll,
        ByteString
"labels"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
labels)
      ]

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

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

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

instance Prelude.NFData DeleteLabelsResponse