{-# 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 #-}
module Amazonka.CodeCommit.CreateRepository
(
CreateRepository (..),
newCreateRepository,
createRepository_repositoryDescription,
createRepository_tags,
createRepository_repositoryName,
CreateRepositoryResponse (..),
newCreateRepositoryResponse,
createRepositoryResponse_repositoryMetadata,
createRepositoryResponse_httpStatus,
)
where
import Amazonka.CodeCommit.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
data CreateRepository = CreateRepository'
{
CreateRepository -> Maybe Text
repositoryDescription :: Prelude.Maybe Prelude.Text,
CreateRepository -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateRepository -> Text
repositoryName :: Prelude.Text
}
deriving (CreateRepository -> CreateRepository -> Bool
(CreateRepository -> CreateRepository -> Bool)
-> (CreateRepository -> CreateRepository -> Bool)
-> Eq CreateRepository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRepository -> CreateRepository -> Bool
$c/= :: CreateRepository -> CreateRepository -> Bool
== :: CreateRepository -> CreateRepository -> Bool
$c== :: CreateRepository -> CreateRepository -> Bool
Prelude.Eq, ReadPrec [CreateRepository]
ReadPrec CreateRepository
Int -> ReadS CreateRepository
ReadS [CreateRepository]
(Int -> ReadS CreateRepository)
-> ReadS [CreateRepository]
-> ReadPrec CreateRepository
-> ReadPrec [CreateRepository]
-> Read CreateRepository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRepository]
$creadListPrec :: ReadPrec [CreateRepository]
readPrec :: ReadPrec CreateRepository
$creadPrec :: ReadPrec CreateRepository
readList :: ReadS [CreateRepository]
$creadList :: ReadS [CreateRepository]
readsPrec :: Int -> ReadS CreateRepository
$creadsPrec :: Int -> ReadS CreateRepository
Prelude.Read, Int -> CreateRepository -> ShowS
[CreateRepository] -> ShowS
CreateRepository -> String
(Int -> CreateRepository -> ShowS)
-> (CreateRepository -> String)
-> ([CreateRepository] -> ShowS)
-> Show CreateRepository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRepository] -> ShowS
$cshowList :: [CreateRepository] -> ShowS
show :: CreateRepository -> String
$cshow :: CreateRepository -> String
showsPrec :: Int -> CreateRepository -> ShowS
$cshowsPrec :: Int -> CreateRepository -> ShowS
Prelude.Show, (forall x. CreateRepository -> Rep CreateRepository x)
-> (forall x. Rep CreateRepository x -> CreateRepository)
-> Generic CreateRepository
forall x. Rep CreateRepository x -> CreateRepository
forall x. CreateRepository -> Rep CreateRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRepository x -> CreateRepository
$cfrom :: forall x. CreateRepository -> Rep CreateRepository x
Prelude.Generic)
newCreateRepository ::
Prelude.Text ->
CreateRepository
newCreateRepository :: Text -> CreateRepository
newCreateRepository Text
pRepositoryName_ =
CreateRepository' :: Maybe Text -> Maybe (HashMap Text Text) -> Text -> CreateRepository
CreateRepository'
{ $sel:repositoryDescription:CreateRepository' :: Maybe Text
repositoryDescription =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateRepository' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:repositoryName:CreateRepository' :: Text
repositoryName = Text
pRepositoryName_
}
createRepository_repositoryDescription :: Lens.Lens' CreateRepository (Prelude.Maybe Prelude.Text)
createRepository_repositoryDescription :: (Maybe Text -> f (Maybe Text))
-> CreateRepository -> f CreateRepository
createRepository_repositoryDescription = (CreateRepository -> Maybe Text)
-> (CreateRepository -> Maybe Text -> CreateRepository)
-> Lens CreateRepository CreateRepository (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRepository' {Maybe Text
repositoryDescription :: Maybe Text
$sel:repositoryDescription:CreateRepository' :: CreateRepository -> Maybe Text
repositoryDescription} -> Maybe Text
repositoryDescription) (\s :: CreateRepository
s@CreateRepository' {} Maybe Text
a -> CreateRepository
s {$sel:repositoryDescription:CreateRepository' :: Maybe Text
repositoryDescription = Maybe Text
a} :: CreateRepository)
createRepository_tags :: Lens.Lens' CreateRepository (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createRepository_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateRepository -> f CreateRepository
createRepository_tags = (CreateRepository -> Maybe (HashMap Text Text))
-> (CreateRepository
-> Maybe (HashMap Text Text) -> CreateRepository)
-> Lens
CreateRepository
CreateRepository
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRepository' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateRepository' :: CreateRepository -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateRepository
s@CreateRepository' {} Maybe (HashMap Text Text)
a -> CreateRepository
s {$sel:tags:CreateRepository' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateRepository) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateRepository -> f CreateRepository)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateRepository
-> f CreateRepository
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text 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
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRepository_repositoryName :: Lens.Lens' CreateRepository Prelude.Text
createRepository_repositoryName :: (Text -> f Text) -> CreateRepository -> f CreateRepository
createRepository_repositoryName = (CreateRepository -> Text)
-> (CreateRepository -> Text -> CreateRepository)
-> Lens CreateRepository CreateRepository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRepository' {Text
repositoryName :: Text
$sel:repositoryName:CreateRepository' :: CreateRepository -> Text
repositoryName} -> Text
repositoryName) (\s :: CreateRepository
s@CreateRepository' {} Text
a -> CreateRepository
s {$sel:repositoryName:CreateRepository' :: Text
repositoryName = Text
a} :: CreateRepository)
instance Core.AWSRequest CreateRepository where
type
AWSResponse CreateRepository =
CreateRepositoryResponse
request :: CreateRepository -> Request CreateRepository
request = Service -> CreateRepository -> Request CreateRepository
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateRepository
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRepository)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateRepository))
-> Logger
-> Service
-> Proxy CreateRepository
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRepository)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe RepositoryMetadata -> Int -> CreateRepositoryResponse
CreateRepositoryResponse'
(Maybe RepositoryMetadata -> Int -> CreateRepositoryResponse)
-> Either String (Maybe RepositoryMetadata)
-> Either String (Int -> CreateRepositoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RepositoryMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"repositoryMetadata")
Either String (Int -> CreateRepositoryResponse)
-> Either String Int -> Either String CreateRepositoryResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateRepository
instance Prelude.NFData CreateRepository
instance Core.ToHeaders CreateRepository where
toHeaders :: CreateRepository -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateRepository -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeCommit_20150413.CreateRepository" ::
Prelude.ByteString
),
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 CreateRepository where
toJSON :: CreateRepository -> Value
toJSON CreateRepository' {Maybe Text
Maybe (HashMap Text Text)
Text
repositoryName :: Text
tags :: Maybe (HashMap Text Text)
repositoryDescription :: Maybe Text
$sel:repositoryName:CreateRepository' :: CreateRepository -> Text
$sel:tags:CreateRepository' :: CreateRepository -> Maybe (HashMap Text Text)
$sel:repositoryDescription:CreateRepository' :: CreateRepository -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"repositoryDescription" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
repositoryDescription,
(Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
]
)
instance Core.ToPath CreateRepository where
toPath :: CreateRepository -> ByteString
toPath = ByteString -> CreateRepository -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateRepository where
toQuery :: CreateRepository -> QueryString
toQuery = QueryString -> CreateRepository -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateRepositoryResponse = CreateRepositoryResponse'
{
CreateRepositoryResponse -> Maybe RepositoryMetadata
repositoryMetadata :: Prelude.Maybe RepositoryMetadata,
CreateRepositoryResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateRepositoryResponse -> CreateRepositoryResponse -> Bool
(CreateRepositoryResponse -> CreateRepositoryResponse -> Bool)
-> (CreateRepositoryResponse -> CreateRepositoryResponse -> Bool)
-> Eq CreateRepositoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRepositoryResponse -> CreateRepositoryResponse -> Bool
$c/= :: CreateRepositoryResponse -> CreateRepositoryResponse -> Bool
== :: CreateRepositoryResponse -> CreateRepositoryResponse -> Bool
$c== :: CreateRepositoryResponse -> CreateRepositoryResponse -> Bool
Prelude.Eq, ReadPrec [CreateRepositoryResponse]
ReadPrec CreateRepositoryResponse
Int -> ReadS CreateRepositoryResponse
ReadS [CreateRepositoryResponse]
(Int -> ReadS CreateRepositoryResponse)
-> ReadS [CreateRepositoryResponse]
-> ReadPrec CreateRepositoryResponse
-> ReadPrec [CreateRepositoryResponse]
-> Read CreateRepositoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRepositoryResponse]
$creadListPrec :: ReadPrec [CreateRepositoryResponse]
readPrec :: ReadPrec CreateRepositoryResponse
$creadPrec :: ReadPrec CreateRepositoryResponse
readList :: ReadS [CreateRepositoryResponse]
$creadList :: ReadS [CreateRepositoryResponse]
readsPrec :: Int -> ReadS CreateRepositoryResponse
$creadsPrec :: Int -> ReadS CreateRepositoryResponse
Prelude.Read, Int -> CreateRepositoryResponse -> ShowS
[CreateRepositoryResponse] -> ShowS
CreateRepositoryResponse -> String
(Int -> CreateRepositoryResponse -> ShowS)
-> (CreateRepositoryResponse -> String)
-> ([CreateRepositoryResponse] -> ShowS)
-> Show CreateRepositoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRepositoryResponse] -> ShowS
$cshowList :: [CreateRepositoryResponse] -> ShowS
show :: CreateRepositoryResponse -> String
$cshow :: CreateRepositoryResponse -> String
showsPrec :: Int -> CreateRepositoryResponse -> ShowS
$cshowsPrec :: Int -> CreateRepositoryResponse -> ShowS
Prelude.Show, (forall x.
CreateRepositoryResponse -> Rep CreateRepositoryResponse x)
-> (forall x.
Rep CreateRepositoryResponse x -> CreateRepositoryResponse)
-> Generic CreateRepositoryResponse
forall x.
Rep CreateRepositoryResponse x -> CreateRepositoryResponse
forall x.
CreateRepositoryResponse -> Rep CreateRepositoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateRepositoryResponse x -> CreateRepositoryResponse
$cfrom :: forall x.
CreateRepositoryResponse -> Rep CreateRepositoryResponse x
Prelude.Generic)
newCreateRepositoryResponse ::
Prelude.Int ->
CreateRepositoryResponse
newCreateRepositoryResponse :: Int -> CreateRepositoryResponse
newCreateRepositoryResponse Int
pHttpStatus_ =
CreateRepositoryResponse' :: Maybe RepositoryMetadata -> Int -> CreateRepositoryResponse
CreateRepositoryResponse'
{ $sel:repositoryMetadata:CreateRepositoryResponse' :: Maybe RepositoryMetadata
repositoryMetadata =
Maybe RepositoryMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateRepositoryResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createRepositoryResponse_repositoryMetadata :: Lens.Lens' CreateRepositoryResponse (Prelude.Maybe RepositoryMetadata)
createRepositoryResponse_repositoryMetadata :: (Maybe RepositoryMetadata -> f (Maybe RepositoryMetadata))
-> CreateRepositoryResponse -> f CreateRepositoryResponse
createRepositoryResponse_repositoryMetadata = (CreateRepositoryResponse -> Maybe RepositoryMetadata)
-> (CreateRepositoryResponse
-> Maybe RepositoryMetadata -> CreateRepositoryResponse)
-> Lens
CreateRepositoryResponse
CreateRepositoryResponse
(Maybe RepositoryMetadata)
(Maybe RepositoryMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRepositoryResponse' {Maybe RepositoryMetadata
repositoryMetadata :: Maybe RepositoryMetadata
$sel:repositoryMetadata:CreateRepositoryResponse' :: CreateRepositoryResponse -> Maybe RepositoryMetadata
repositoryMetadata} -> Maybe RepositoryMetadata
repositoryMetadata) (\s :: CreateRepositoryResponse
s@CreateRepositoryResponse' {} Maybe RepositoryMetadata
a -> CreateRepositoryResponse
s {$sel:repositoryMetadata:CreateRepositoryResponse' :: Maybe RepositoryMetadata
repositoryMetadata = Maybe RepositoryMetadata
a} :: CreateRepositoryResponse)
createRepositoryResponse_httpStatus :: Lens.Lens' CreateRepositoryResponse Prelude.Int
createRepositoryResponse_httpStatus :: (Int -> f Int)
-> CreateRepositoryResponse -> f CreateRepositoryResponse
createRepositoryResponse_httpStatus = (CreateRepositoryResponse -> Int)
-> (CreateRepositoryResponse -> Int -> CreateRepositoryResponse)
-> Lens CreateRepositoryResponse CreateRepositoryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRepositoryResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRepositoryResponse' :: CreateRepositoryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRepositoryResponse
s@CreateRepositoryResponse' {} Int
a -> CreateRepositoryResponse
s {$sel:httpStatus:CreateRepositoryResponse' :: Int
httpStatus = Int
a} :: CreateRepositoryResponse)
instance Prelude.NFData CreateRepositoryResponse