{-# 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.CloudDirectory.CreateIndex
(
CreateIndex (..),
newCreateIndex,
createIndex_parentReference,
createIndex_linkName,
createIndex_directoryArn,
createIndex_orderedIndexedAttributeList,
createIndex_isUnique,
CreateIndexResponse (..),
newCreateIndexResponse,
createIndexResponse_objectIdentifier,
createIndexResponse_httpStatus,
)
where
import Amazonka.CloudDirectory.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 CreateIndex = CreateIndex'
{
CreateIndex -> Maybe ObjectReference
parentReference :: Prelude.Maybe ObjectReference,
CreateIndex -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
CreateIndex -> Text
directoryArn :: Prelude.Text,
CreateIndex -> [AttributeKey]
orderedIndexedAttributeList :: [AttributeKey],
CreateIndex -> Bool
isUnique :: Prelude.Bool
}
deriving (CreateIndex -> CreateIndex -> Bool
(CreateIndex -> CreateIndex -> Bool)
-> (CreateIndex -> CreateIndex -> Bool) -> Eq CreateIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIndex -> CreateIndex -> Bool
$c/= :: CreateIndex -> CreateIndex -> Bool
== :: CreateIndex -> CreateIndex -> Bool
$c== :: CreateIndex -> CreateIndex -> Bool
Prelude.Eq, ReadPrec [CreateIndex]
ReadPrec CreateIndex
Int -> ReadS CreateIndex
ReadS [CreateIndex]
(Int -> ReadS CreateIndex)
-> ReadS [CreateIndex]
-> ReadPrec CreateIndex
-> ReadPrec [CreateIndex]
-> Read CreateIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIndex]
$creadListPrec :: ReadPrec [CreateIndex]
readPrec :: ReadPrec CreateIndex
$creadPrec :: ReadPrec CreateIndex
readList :: ReadS [CreateIndex]
$creadList :: ReadS [CreateIndex]
readsPrec :: Int -> ReadS CreateIndex
$creadsPrec :: Int -> ReadS CreateIndex
Prelude.Read, Int -> CreateIndex -> ShowS
[CreateIndex] -> ShowS
CreateIndex -> String
(Int -> CreateIndex -> ShowS)
-> (CreateIndex -> String)
-> ([CreateIndex] -> ShowS)
-> Show CreateIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIndex] -> ShowS
$cshowList :: [CreateIndex] -> ShowS
show :: CreateIndex -> String
$cshow :: CreateIndex -> String
showsPrec :: Int -> CreateIndex -> ShowS
$cshowsPrec :: Int -> CreateIndex -> ShowS
Prelude.Show, (forall x. CreateIndex -> Rep CreateIndex x)
-> (forall x. Rep CreateIndex x -> CreateIndex)
-> Generic CreateIndex
forall x. Rep CreateIndex x -> CreateIndex
forall x. CreateIndex -> Rep CreateIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIndex x -> CreateIndex
$cfrom :: forall x. CreateIndex -> Rep CreateIndex x
Prelude.Generic)
newCreateIndex ::
Prelude.Text ->
Prelude.Bool ->
CreateIndex
newCreateIndex :: Text -> Bool -> CreateIndex
newCreateIndex Text
pDirectoryArn_ Bool
pIsUnique_ =
CreateIndex' :: Maybe ObjectReference
-> Maybe Text -> Text -> [AttributeKey] -> Bool -> CreateIndex
CreateIndex'
{ $sel:parentReference:CreateIndex' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
forall a. Maybe a
Prelude.Nothing,
$sel:linkName:CreateIndex' :: Maybe Text
linkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:directoryArn:CreateIndex' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:orderedIndexedAttributeList:CreateIndex' :: [AttributeKey]
orderedIndexedAttributeList = [AttributeKey]
forall a. Monoid a => a
Prelude.mempty,
$sel:isUnique:CreateIndex' :: Bool
isUnique = Bool
pIsUnique_
}
createIndex_parentReference :: Lens.Lens' CreateIndex (Prelude.Maybe ObjectReference)
createIndex_parentReference :: (Maybe ObjectReference -> f (Maybe ObjectReference))
-> CreateIndex -> f CreateIndex
createIndex_parentReference = (CreateIndex -> Maybe ObjectReference)
-> (CreateIndex -> Maybe ObjectReference -> CreateIndex)
-> Lens
CreateIndex
CreateIndex
(Maybe ObjectReference)
(Maybe ObjectReference)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndex' {Maybe ObjectReference
parentReference :: Maybe ObjectReference
$sel:parentReference:CreateIndex' :: CreateIndex -> Maybe ObjectReference
parentReference} -> Maybe ObjectReference
parentReference) (\s :: CreateIndex
s@CreateIndex' {} Maybe ObjectReference
a -> CreateIndex
s {$sel:parentReference:CreateIndex' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
a} :: CreateIndex)
createIndex_linkName :: Lens.Lens' CreateIndex (Prelude.Maybe Prelude.Text)
createIndex_linkName :: (Maybe Text -> f (Maybe Text)) -> CreateIndex -> f CreateIndex
createIndex_linkName = (CreateIndex -> Maybe Text)
-> (CreateIndex -> Maybe Text -> CreateIndex)
-> Lens CreateIndex CreateIndex (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndex' {Maybe Text
linkName :: Maybe Text
$sel:linkName:CreateIndex' :: CreateIndex -> Maybe Text
linkName} -> Maybe Text
linkName) (\s :: CreateIndex
s@CreateIndex' {} Maybe Text
a -> CreateIndex
s {$sel:linkName:CreateIndex' :: Maybe Text
linkName = Maybe Text
a} :: CreateIndex)
createIndex_directoryArn :: Lens.Lens' CreateIndex Prelude.Text
createIndex_directoryArn :: (Text -> f Text) -> CreateIndex -> f CreateIndex
createIndex_directoryArn = (CreateIndex -> Text)
-> (CreateIndex -> Text -> CreateIndex)
-> Lens CreateIndex CreateIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndex' {Text
directoryArn :: Text
$sel:directoryArn:CreateIndex' :: CreateIndex -> Text
directoryArn} -> Text
directoryArn) (\s :: CreateIndex
s@CreateIndex' {} Text
a -> CreateIndex
s {$sel:directoryArn:CreateIndex' :: Text
directoryArn = Text
a} :: CreateIndex)
createIndex_orderedIndexedAttributeList :: Lens.Lens' CreateIndex [AttributeKey]
createIndex_orderedIndexedAttributeList :: ([AttributeKey] -> f [AttributeKey])
-> CreateIndex -> f CreateIndex
createIndex_orderedIndexedAttributeList = (CreateIndex -> [AttributeKey])
-> (CreateIndex -> [AttributeKey] -> CreateIndex)
-> Lens CreateIndex CreateIndex [AttributeKey] [AttributeKey]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndex' {[AttributeKey]
orderedIndexedAttributeList :: [AttributeKey]
$sel:orderedIndexedAttributeList:CreateIndex' :: CreateIndex -> [AttributeKey]
orderedIndexedAttributeList} -> [AttributeKey]
orderedIndexedAttributeList) (\s :: CreateIndex
s@CreateIndex' {} [AttributeKey]
a -> CreateIndex
s {$sel:orderedIndexedAttributeList:CreateIndex' :: [AttributeKey]
orderedIndexedAttributeList = [AttributeKey]
a} :: CreateIndex) (([AttributeKey] -> f [AttributeKey])
-> CreateIndex -> f CreateIndex)
-> (([AttributeKey] -> f [AttributeKey])
-> [AttributeKey] -> f [AttributeKey])
-> ([AttributeKey] -> f [AttributeKey])
-> CreateIndex
-> f CreateIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AttributeKey] -> f [AttributeKey])
-> [AttributeKey] -> f [AttributeKey]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createIndex_isUnique :: Lens.Lens' CreateIndex Prelude.Bool
createIndex_isUnique :: (Bool -> f Bool) -> CreateIndex -> f CreateIndex
createIndex_isUnique = (CreateIndex -> Bool)
-> (CreateIndex -> Bool -> CreateIndex)
-> Lens CreateIndex CreateIndex Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndex' {Bool
isUnique :: Bool
$sel:isUnique:CreateIndex' :: CreateIndex -> Bool
isUnique} -> Bool
isUnique) (\s :: CreateIndex
s@CreateIndex' {} Bool
a -> CreateIndex
s {$sel:isUnique:CreateIndex' :: Bool
isUnique = Bool
a} :: CreateIndex)
instance Core.AWSRequest CreateIndex where
type AWSResponse CreateIndex = CreateIndexResponse
request :: CreateIndex -> Request CreateIndex
request = Service -> CreateIndex -> Request CreateIndex
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIndex)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateIndex))
-> Logger
-> Service
-> Proxy CreateIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIndex)))
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 Text -> Int -> CreateIndexResponse
CreateIndexResponse'
(Maybe Text -> Int -> CreateIndexResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateIndexResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ObjectIdentifier")
Either String (Int -> CreateIndexResponse)
-> Either String Int -> Either String CreateIndexResponse
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 CreateIndex
instance Prelude.NFData CreateIndex
instance Core.ToHeaders CreateIndex where
toHeaders :: CreateIndex -> ResponseHeaders
toHeaders CreateIndex' {Bool
[AttributeKey]
Maybe Text
Maybe ObjectReference
Text
isUnique :: Bool
orderedIndexedAttributeList :: [AttributeKey]
directoryArn :: Text
linkName :: Maybe Text
parentReference :: Maybe ObjectReference
$sel:isUnique:CreateIndex' :: CreateIndex -> Bool
$sel:orderedIndexedAttributeList:CreateIndex' :: CreateIndex -> [AttributeKey]
$sel:directoryArn:CreateIndex' :: CreateIndex -> Text
$sel:linkName:CreateIndex' :: CreateIndex -> Maybe Text
$sel:parentReference:CreateIndex' :: CreateIndex -> Maybe ObjectReference
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn]
instance Core.ToJSON CreateIndex where
toJSON :: CreateIndex -> Value
toJSON CreateIndex' {Bool
[AttributeKey]
Maybe Text
Maybe ObjectReference
Text
isUnique :: Bool
orderedIndexedAttributeList :: [AttributeKey]
directoryArn :: Text
linkName :: Maybe Text
parentReference :: Maybe ObjectReference
$sel:isUnique:CreateIndex' :: CreateIndex -> Bool
$sel:orderedIndexedAttributeList:CreateIndex' :: CreateIndex -> [AttributeKey]
$sel:directoryArn:CreateIndex' :: CreateIndex -> Text
$sel:linkName:CreateIndex' :: CreateIndex -> Maybe Text
$sel:parentReference:CreateIndex' :: CreateIndex -> Maybe ObjectReference
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ParentReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ObjectReference -> Pair) -> Maybe ObjectReference -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ObjectReference
parentReference,
(Text
"LinkName" 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
linkName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"OrderedIndexedAttributeList"
Text -> [AttributeKey] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [AttributeKey]
orderedIndexedAttributeList
),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IsUnique" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
isUnique)
]
)
instance Core.ToPath CreateIndex where
toPath :: CreateIndex -> ByteString
toPath =
ByteString -> CreateIndex -> ByteString
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/index"
instance Core.ToQuery CreateIndex where
toQuery :: CreateIndex -> QueryString
toQuery = QueryString -> CreateIndex -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateIndexResponse = CreateIndexResponse'
{
CreateIndexResponse -> Maybe Text
objectIdentifier :: Prelude.Maybe Prelude.Text,
CreateIndexResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateIndexResponse -> CreateIndexResponse -> Bool
(CreateIndexResponse -> CreateIndexResponse -> Bool)
-> (CreateIndexResponse -> CreateIndexResponse -> Bool)
-> Eq CreateIndexResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIndexResponse -> CreateIndexResponse -> Bool
$c/= :: CreateIndexResponse -> CreateIndexResponse -> Bool
== :: CreateIndexResponse -> CreateIndexResponse -> Bool
$c== :: CreateIndexResponse -> CreateIndexResponse -> Bool
Prelude.Eq, ReadPrec [CreateIndexResponse]
ReadPrec CreateIndexResponse
Int -> ReadS CreateIndexResponse
ReadS [CreateIndexResponse]
(Int -> ReadS CreateIndexResponse)
-> ReadS [CreateIndexResponse]
-> ReadPrec CreateIndexResponse
-> ReadPrec [CreateIndexResponse]
-> Read CreateIndexResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIndexResponse]
$creadListPrec :: ReadPrec [CreateIndexResponse]
readPrec :: ReadPrec CreateIndexResponse
$creadPrec :: ReadPrec CreateIndexResponse
readList :: ReadS [CreateIndexResponse]
$creadList :: ReadS [CreateIndexResponse]
readsPrec :: Int -> ReadS CreateIndexResponse
$creadsPrec :: Int -> ReadS CreateIndexResponse
Prelude.Read, Int -> CreateIndexResponse -> ShowS
[CreateIndexResponse] -> ShowS
CreateIndexResponse -> String
(Int -> CreateIndexResponse -> ShowS)
-> (CreateIndexResponse -> String)
-> ([CreateIndexResponse] -> ShowS)
-> Show CreateIndexResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIndexResponse] -> ShowS
$cshowList :: [CreateIndexResponse] -> ShowS
show :: CreateIndexResponse -> String
$cshow :: CreateIndexResponse -> String
showsPrec :: Int -> CreateIndexResponse -> ShowS
$cshowsPrec :: Int -> CreateIndexResponse -> ShowS
Prelude.Show, (forall x. CreateIndexResponse -> Rep CreateIndexResponse x)
-> (forall x. Rep CreateIndexResponse x -> CreateIndexResponse)
-> Generic CreateIndexResponse
forall x. Rep CreateIndexResponse x -> CreateIndexResponse
forall x. CreateIndexResponse -> Rep CreateIndexResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIndexResponse x -> CreateIndexResponse
$cfrom :: forall x. CreateIndexResponse -> Rep CreateIndexResponse x
Prelude.Generic)
newCreateIndexResponse ::
Prelude.Int ->
CreateIndexResponse
newCreateIndexResponse :: Int -> CreateIndexResponse
newCreateIndexResponse Int
pHttpStatus_ =
CreateIndexResponse' :: Maybe Text -> Int -> CreateIndexResponse
CreateIndexResponse'
{ $sel:objectIdentifier:CreateIndexResponse' :: Maybe Text
objectIdentifier =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateIndexResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createIndexResponse_objectIdentifier :: Lens.Lens' CreateIndexResponse (Prelude.Maybe Prelude.Text)
createIndexResponse_objectIdentifier :: (Maybe Text -> f (Maybe Text))
-> CreateIndexResponse -> f CreateIndexResponse
createIndexResponse_objectIdentifier = (CreateIndexResponse -> Maybe Text)
-> (CreateIndexResponse -> Maybe Text -> CreateIndexResponse)
-> Lens
CreateIndexResponse CreateIndexResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndexResponse' {Maybe Text
objectIdentifier :: Maybe Text
$sel:objectIdentifier:CreateIndexResponse' :: CreateIndexResponse -> Maybe Text
objectIdentifier} -> Maybe Text
objectIdentifier) (\s :: CreateIndexResponse
s@CreateIndexResponse' {} Maybe Text
a -> CreateIndexResponse
s {$sel:objectIdentifier:CreateIndexResponse' :: Maybe Text
objectIdentifier = Maybe Text
a} :: CreateIndexResponse)
createIndexResponse_httpStatus :: Lens.Lens' CreateIndexResponse Prelude.Int
createIndexResponse_httpStatus :: (Int -> f Int) -> CreateIndexResponse -> f CreateIndexResponse
createIndexResponse_httpStatus = (CreateIndexResponse -> Int)
-> (CreateIndexResponse -> Int -> CreateIndexResponse)
-> Lens CreateIndexResponse CreateIndexResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIndexResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateIndexResponse' :: CreateIndexResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateIndexResponse
s@CreateIndexResponse' {} Int
a -> CreateIndexResponse
s {$sel:httpStatus:CreateIndexResponse' :: Int
httpStatus = Int
a} :: CreateIndexResponse)
instance Prelude.NFData CreateIndexResponse