{-# 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.CreateLabels
-- 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)
--
-- Adds the specified list of labels to the given resource (a document or
-- folder)
module Amazonka.WorkDocs.CreateLabels
  ( -- * Creating a Request
    CreateLabels (..),
    newCreateLabels,

    -- * Request Lenses
    createLabels_authenticationToken,
    createLabels_resourceId,
    createLabels_labels,

    -- * Destructuring the Response
    CreateLabelsResponse (..),
    newCreateLabelsResponse,

    -- * Response Lenses
    createLabelsResponse_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:/ 'newCreateLabels' smart constructor.
data CreateLabels = CreateLabels'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    CreateLabels -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ID of the resource.
    CreateLabels -> Text
resourceId :: Prelude.Text,
    -- | List of labels to add to the resource.
    CreateLabels -> [Text]
labels :: [Prelude.Text]
  }
  deriving (CreateLabels -> CreateLabels -> Bool
(CreateLabels -> CreateLabels -> Bool)
-> (CreateLabels -> CreateLabels -> Bool) -> Eq CreateLabels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLabels -> CreateLabels -> Bool
$c/= :: CreateLabels -> CreateLabels -> Bool
== :: CreateLabels -> CreateLabels -> Bool
$c== :: CreateLabels -> CreateLabels -> Bool
Prelude.Eq, Int -> CreateLabels -> ShowS
[CreateLabels] -> ShowS
CreateLabels -> String
(Int -> CreateLabels -> ShowS)
-> (CreateLabels -> String)
-> ([CreateLabels] -> ShowS)
-> Show CreateLabels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLabels] -> ShowS
$cshowList :: [CreateLabels] -> ShowS
show :: CreateLabels -> String
$cshow :: CreateLabels -> String
showsPrec :: Int -> CreateLabels -> ShowS
$cshowsPrec :: Int -> CreateLabels -> ShowS
Prelude.Show, (forall x. CreateLabels -> Rep CreateLabels x)
-> (forall x. Rep CreateLabels x -> CreateLabels)
-> Generic CreateLabels
forall x. Rep CreateLabels x -> CreateLabels
forall x. CreateLabels -> Rep CreateLabels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLabels x -> CreateLabels
$cfrom :: forall x. CreateLabels -> Rep CreateLabels x
Prelude.Generic)

-- |
-- Create a value of 'CreateLabels' 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:
--
-- 'authenticationToken', 'createLabels_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'resourceId', 'createLabels_resourceId' - The ID of the resource.
--
-- 'labels', 'createLabels_labels' - List of labels to add to the resource.
newCreateLabels ::
  -- | 'resourceId'
  Prelude.Text ->
  CreateLabels
newCreateLabels :: Text -> CreateLabels
newCreateLabels Text
pResourceId_ =
  CreateLabels' :: Maybe (Sensitive Text) -> Text -> [Text] -> CreateLabels
CreateLabels'
    { $sel:authenticationToken:CreateLabels' :: Maybe (Sensitive Text)
authenticationToken =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceId:CreateLabels' :: Text
resourceId = Text
pResourceId_,
      $sel:labels:CreateLabels' :: [Text]
labels = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | List of labels to add to the resource.
createLabels_labels :: Lens.Lens' CreateLabels [Prelude.Text]
createLabels_labels :: ([Text] -> f [Text]) -> CreateLabels -> f CreateLabels
createLabels_labels = (CreateLabels -> [Text])
-> (CreateLabels -> [Text] -> CreateLabels)
-> Lens CreateLabels CreateLabels [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLabels' {[Text]
labels :: [Text]
$sel:labels:CreateLabels' :: CreateLabels -> [Text]
labels} -> [Text]
labels) (\s :: CreateLabels
s@CreateLabels' {} [Text]
a -> CreateLabels
s {$sel:labels:CreateLabels' :: [Text]
labels = [Text]
a} :: CreateLabels) (([Text] -> f [Text]) -> CreateLabels -> f CreateLabels)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateLabels
-> f CreateLabels
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 CreateLabels where
  type AWSResponse CreateLabels = CreateLabelsResponse
  request :: CreateLabels -> Request CreateLabels
request = Service -> CreateLabels -> Request CreateLabels
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateLabels)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateLabels))
-> Logger
-> Service
-> Proxy CreateLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateLabels)))
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 -> CreateLabelsResponse
CreateLabelsResponse'
            (Int -> CreateLabelsResponse)
-> Either String Int -> Either String CreateLabelsResponse
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 CreateLabels

instance Prelude.NFData CreateLabels

instance Core.ToHeaders CreateLabels where
  toHeaders :: CreateLabels -> ResponseHeaders
toHeaders CreateLabels' {[Text]
Maybe (Sensitive Text)
Text
labels :: [Text]
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:labels:CreateLabels' :: CreateLabels -> [Text]
$sel:resourceId:CreateLabels' :: CreateLabels -> Text
$sel:authenticationToken:CreateLabels' :: CreateLabels -> Maybe (Sensitive Text)
..} =
    [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.ToJSON CreateLabels where
  toJSON :: CreateLabels -> Value
toJSON CreateLabels' {[Text]
Maybe (Sensitive Text)
Text
labels :: [Text]
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:labels:CreateLabels' :: CreateLabels -> [Text]
$sel:resourceId:CreateLabels' :: CreateLabels -> Text
$sel:authenticationToken:CreateLabels' :: CreateLabels -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Labels" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
labels)]
      )

instance Core.ToPath CreateLabels where
  toPath :: CreateLabels -> ByteString
toPath CreateLabels' {[Text]
Maybe (Sensitive Text)
Text
labels :: [Text]
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
$sel:labels:CreateLabels' :: CreateLabels -> [Text]
$sel:resourceId:CreateLabels' :: CreateLabels -> Text
$sel:authenticationToken:CreateLabels' :: CreateLabels -> Maybe (Sensitive Text)
..} =
    [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 CreateLabels where
  toQuery :: CreateLabels -> QueryString
toQuery = QueryString -> CreateLabels -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

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

instance Prelude.NFData CreateLabelsResponse