{-# LANGUAGE DataKinds                   #-}
{-# LANGUAGE DeriveGeneric               #-}
{-# LANGUAGE FlexibleInstances           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving  #-}
{-# LANGUAGE LambdaCase                  #-}
{-# LANGUAGE NoImplicitPrelude           #-}
{-# LANGUAGE OverloadedStrings           #-}
{-# LANGUAGE RecordWildCards             #-}
{-# LANGUAGE TypeFamilies                #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}

-- Module      : Network.AWS.KMS.UpdateKeyDescription
-- Copyright   : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
-- License     : This Source Code Form is subject to the terms of
--               the Mozilla Public License, v. 2.0.
--               A copy of the MPL can be found in the LICENSE file or
--               you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--
-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- | Updates the description of a key.
--
-- <http://docs.aws.amazon.com/kms/latest/APIReference/API_UpdateKeyDescription.html>
module Network.AWS.KMS.UpdateKeyDescription
    (
    -- * Request
      UpdateKeyDescription
    -- ** Request constructor
    , updateKeyDescription
    -- ** Request lenses
    , ukdDescription
    , ukdKeyId

    -- * Response
    , UpdateKeyDescriptionResponse
    -- ** Response constructor
    , updateKeyDescriptionResponse
    ) where

import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.KMS.Types
import qualified GHC.Exts

data UpdateKeyDescription = UpdateKeyDescription
    { _ukdDescription :: Text
    , _ukdKeyId       :: Text
    } deriving (Eq, Ord, Read, Show)

-- | 'UpdateKeyDescription' constructor.
--
-- The fields accessible through corresponding lenses are:
--
-- * 'ukdDescription' @::@ 'Text'
--
-- * 'ukdKeyId' @::@ 'Text'
--
updateKeyDescription :: Text -- ^ 'ukdKeyId'
                     -> Text -- ^ 'ukdDescription'
                     -> UpdateKeyDescription
updateKeyDescription p1 p2 = UpdateKeyDescription
    { _ukdKeyId       = p1
    , _ukdDescription = p2
    }

-- | New description for the key.
ukdDescription :: Lens' UpdateKeyDescription Text
ukdDescription = lens _ukdDescription (\s a -> s { _ukdDescription = a })

-- | A unique identifier for the customer master key. This value can be a globally
-- unique identifier or the fully specified ARN to a key.  Key ARN Example -
-- arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012 Globally Unique Key ID Example - 12345678-1234-1234-123456789012
--
ukdKeyId :: Lens' UpdateKeyDescription Text
ukdKeyId = lens _ukdKeyId (\s a -> s { _ukdKeyId = a })

data UpdateKeyDescriptionResponse = UpdateKeyDescriptionResponse
    deriving (Eq, Ord, Read, Show, Generic)

-- | 'UpdateKeyDescriptionResponse' constructor.
updateKeyDescriptionResponse :: UpdateKeyDescriptionResponse
updateKeyDescriptionResponse = UpdateKeyDescriptionResponse

instance ToPath UpdateKeyDescription where
    toPath = const "/"

instance ToQuery UpdateKeyDescription where
    toQuery = const mempty

instance ToHeaders UpdateKeyDescription

instance ToJSON UpdateKeyDescription where
    toJSON UpdateKeyDescription{..} = object
        [ "KeyId"       .= _ukdKeyId
        , "Description" .= _ukdDescription
        ]

instance AWSRequest UpdateKeyDescription where
    type Sv UpdateKeyDescription = KMS
    type Rs UpdateKeyDescription = UpdateKeyDescriptionResponse

    request  = post "UpdateKeyDescription"
    response = nullResponse UpdateKeyDescriptionResponse