amazonka-datapipeline-0.3.4: gen/Network/AWS/DataPipeline/CreatePipeline.hs
{-# 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.DataPipeline.CreatePipeline
-- 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.
-- | Creates a new, empty pipeline. Use 'PutPipelineDefinition' to populate the
-- pipeline.
--
-- <http://docs.aws.amazon.com/datapipeline/latest/APIReference/API_CreatePipeline.html>
module Network.AWS.DataPipeline.CreatePipeline
(
-- * Request
CreatePipeline
-- ** Request constructor
, createPipeline
-- ** Request lenses
, cpDescription
, cpName
, cpTags
, cpUniqueId
-- * Response
, CreatePipelineResponse
-- ** Response constructor
, createPipelineResponse
-- ** Response lenses
, cprPipelineId
) where
import Network.AWS.Data (Object)
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.DataPipeline.Types
import qualified GHC.Exts
data CreatePipeline = CreatePipeline
{ _cpDescription :: Maybe Text
, _cpName :: Text
, _cpTags :: List "tags" Tag
, _cpUniqueId :: Text
} deriving (Eq, Read, Show)
-- | 'CreatePipeline' constructor.
--
-- The fields accessible through corresponding lenses are:
--
-- * 'cpDescription' @::@ 'Maybe' 'Text'
--
-- * 'cpName' @::@ 'Text'
--
-- * 'cpTags' @::@ ['Tag']
--
-- * 'cpUniqueId' @::@ 'Text'
--
createPipeline :: Text -- ^ 'cpName'
-> Text -- ^ 'cpUniqueId'
-> CreatePipeline
createPipeline p1 p2 = CreatePipeline
{ _cpName = p1
, _cpUniqueId = p2
, _cpDescription = Nothing
, _cpTags = mempty
}
-- | The description for the pipeline.
cpDescription :: Lens' CreatePipeline (Maybe Text)
cpDescription = lens _cpDescription (\s a -> s { _cpDescription = a })
-- | The name for the pipeline. You can use the same name for multiple pipelines
-- associated with your AWS account, because AWS Data Pipeline assigns each
-- pipeline a unique pipeline identifier.
cpName :: Lens' CreatePipeline Text
cpName = lens _cpName (\s a -> s { _cpName = a })
-- | A list of tags to associate with the pipeline at creation. Tags let you
-- control access to pipelines. For more information, see <http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-control-access.html Controlling UserAccess to Pipelines> in the /AWS Data Pipeline Developer Guide/.
cpTags :: Lens' CreatePipeline [Tag]
cpTags = lens _cpTags (\s a -> s { _cpTags = a }) . _List
-- | A unique identifier. This identifier is not the same as the pipeline
-- identifier assigned by AWS Data Pipeline. You are responsible for defining
-- the format and ensuring the uniqueness of this identifier. You use this
-- parameter to ensure idempotency during repeated calls to 'CreatePipeline'. For
-- example, if the first call to 'CreatePipeline' does not succeed, you can pass
-- in the same unique identifier and pipeline name combination on a subsequent
-- call to 'CreatePipeline'. 'CreatePipeline' ensures that if a pipeline already
-- exists with the same name and unique identifier, a new pipeline is not
-- created. Instead, you'll receive the pipeline identifier from the previous
-- attempt. The uniqueness of the name and unique identifier combination is
-- scoped to the AWS account or IAM user credentials.
cpUniqueId :: Lens' CreatePipeline Text
cpUniqueId = lens _cpUniqueId (\s a -> s { _cpUniqueId = a })
newtype CreatePipelineResponse = CreatePipelineResponse
{ _cprPipelineId :: Text
} deriving (Eq, Ord, Read, Show, Monoid, IsString)
-- | 'CreatePipelineResponse' constructor.
--
-- The fields accessible through corresponding lenses are:
--
-- * 'cprPipelineId' @::@ 'Text'
--
createPipelineResponse :: Text -- ^ 'cprPipelineId'
-> CreatePipelineResponse
createPipelineResponse p1 = CreatePipelineResponse
{ _cprPipelineId = p1
}
-- | The ID that AWS Data Pipeline assigns the newly created pipeline. For
-- example, 'df-06372391ZG65EXAMPLE'.
cprPipelineId :: Lens' CreatePipelineResponse Text
cprPipelineId = lens _cprPipelineId (\s a -> s { _cprPipelineId = a })
instance ToPath CreatePipeline where
toPath = const "/"
instance ToQuery CreatePipeline where
toQuery = const mempty
instance ToHeaders CreatePipeline
instance ToJSON CreatePipeline where
toJSON CreatePipeline{..} = object
[ "name" .= _cpName
, "uniqueId" .= _cpUniqueId
, "description" .= _cpDescription
, "tags" .= _cpTags
]
instance AWSRequest CreatePipeline where
type Sv CreatePipeline = DataPipeline
type Rs CreatePipeline = CreatePipelineResponse
request = post "CreatePipeline"
response = jsonResponse
instance FromJSON CreatePipelineResponse where
parseJSON = withObject "CreatePipelineResponse" $ \o -> CreatePipelineResponse
<$> o .: "pipelineId"