{-# 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.SageMaker.CreateContext
(
CreateContext (..),
newCreateContext,
createContext_description,
createContext_tags,
createContext_properties,
createContext_contextName,
createContext_source,
createContext_contextType,
CreateContextResponse (..),
newCreateContextResponse,
createContextResponse_contextArn,
createContextResponse_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.SageMaker.Types
data CreateContext = CreateContext'
{
CreateContext -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateContext -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateContext -> Maybe (HashMap Text Text)
properties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateContext -> Text
contextName :: Prelude.Text,
CreateContext -> ContextSource
source :: ContextSource,
CreateContext -> Text
contextType :: Prelude.Text
}
deriving (CreateContext -> CreateContext -> Bool
(CreateContext -> CreateContext -> Bool)
-> (CreateContext -> CreateContext -> Bool) -> Eq CreateContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContext -> CreateContext -> Bool
$c/= :: CreateContext -> CreateContext -> Bool
== :: CreateContext -> CreateContext -> Bool
$c== :: CreateContext -> CreateContext -> Bool
Prelude.Eq, ReadPrec [CreateContext]
ReadPrec CreateContext
Int -> ReadS CreateContext
ReadS [CreateContext]
(Int -> ReadS CreateContext)
-> ReadS [CreateContext]
-> ReadPrec CreateContext
-> ReadPrec [CreateContext]
-> Read CreateContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContext]
$creadListPrec :: ReadPrec [CreateContext]
readPrec :: ReadPrec CreateContext
$creadPrec :: ReadPrec CreateContext
readList :: ReadS [CreateContext]
$creadList :: ReadS [CreateContext]
readsPrec :: Int -> ReadS CreateContext
$creadsPrec :: Int -> ReadS CreateContext
Prelude.Read, Int -> CreateContext -> ShowS
[CreateContext] -> ShowS
CreateContext -> String
(Int -> CreateContext -> ShowS)
-> (CreateContext -> String)
-> ([CreateContext] -> ShowS)
-> Show CreateContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContext] -> ShowS
$cshowList :: [CreateContext] -> ShowS
show :: CreateContext -> String
$cshow :: CreateContext -> String
showsPrec :: Int -> CreateContext -> ShowS
$cshowsPrec :: Int -> CreateContext -> ShowS
Prelude.Show, (forall x. CreateContext -> Rep CreateContext x)
-> (forall x. Rep CreateContext x -> CreateContext)
-> Generic CreateContext
forall x. Rep CreateContext x -> CreateContext
forall x. CreateContext -> Rep CreateContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContext x -> CreateContext
$cfrom :: forall x. CreateContext -> Rep CreateContext x
Prelude.Generic)
newCreateContext ::
Prelude.Text ->
ContextSource ->
Prelude.Text ->
CreateContext
newCreateContext :: Text -> ContextSource -> Text -> CreateContext
newCreateContext Text
pContextName_ ContextSource
pSource_ Text
pContextType_ =
CreateContext' :: Maybe Text
-> Maybe [Tag]
-> Maybe (HashMap Text Text)
-> Text
-> ContextSource
-> Text
-> CreateContext
CreateContext'
{ $sel:description:CreateContext' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateContext' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:properties:CreateContext' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:contextName:CreateContext' :: Text
contextName = Text
pContextName_,
$sel:source:CreateContext' :: ContextSource
source = ContextSource
pSource_,
$sel:contextType:CreateContext' :: Text
contextType = Text
pContextType_
}
createContext_description :: Lens.Lens' CreateContext (Prelude.Maybe Prelude.Text)
createContext_description :: (Maybe Text -> f (Maybe Text)) -> CreateContext -> f CreateContext
createContext_description = (CreateContext -> Maybe Text)
-> (CreateContext -> Maybe Text -> CreateContext)
-> Lens CreateContext CreateContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContext' {Maybe Text
description :: Maybe Text
$sel:description:CreateContext' :: CreateContext -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateContext
s@CreateContext' {} Maybe Text
a -> CreateContext
s {$sel:description:CreateContext' :: Maybe Text
description = Maybe Text
a} :: CreateContext)
createContext_tags :: Lens.Lens' CreateContext (Prelude.Maybe [Tag])
createContext_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContext -> f CreateContext
createContext_tags = (CreateContext -> Maybe [Tag])
-> (CreateContext -> Maybe [Tag] -> CreateContext)
-> Lens CreateContext CreateContext (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContext' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateContext' :: CreateContext -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateContext
s@CreateContext' {} Maybe [Tag]
a -> CreateContext
s {$sel:tags:CreateContext' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateContext) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContext -> f CreateContext)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateContext
-> f CreateContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createContext_properties :: Lens.Lens' CreateContext (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createContext_properties :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateContext -> f CreateContext
createContext_properties = (CreateContext -> Maybe (HashMap Text Text))
-> (CreateContext -> Maybe (HashMap Text Text) -> CreateContext)
-> Lens
CreateContext
CreateContext
(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 (\CreateContext' {Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
$sel:properties:CreateContext' :: CreateContext -> Maybe (HashMap Text Text)
properties} -> Maybe (HashMap Text Text)
properties) (\s :: CreateContext
s@CreateContext' {} Maybe (HashMap Text Text)
a -> CreateContext
s {$sel:properties:CreateContext' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
a} :: CreateContext) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateContext -> f CreateContext)
-> ((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)))
-> CreateContext
-> f CreateContext
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
createContext_contextName :: Lens.Lens' CreateContext Prelude.Text
createContext_contextName :: (Text -> f Text) -> CreateContext -> f CreateContext
createContext_contextName = (CreateContext -> Text)
-> (CreateContext -> Text -> CreateContext)
-> Lens CreateContext CreateContext Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContext' {Text
contextName :: Text
$sel:contextName:CreateContext' :: CreateContext -> Text
contextName} -> Text
contextName) (\s :: CreateContext
s@CreateContext' {} Text
a -> CreateContext
s {$sel:contextName:CreateContext' :: Text
contextName = Text
a} :: CreateContext)
createContext_source :: Lens.Lens' CreateContext ContextSource
createContext_source :: (ContextSource -> f ContextSource)
-> CreateContext -> f CreateContext
createContext_source = (CreateContext -> ContextSource)
-> (CreateContext -> ContextSource -> CreateContext)
-> Lens CreateContext CreateContext ContextSource ContextSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContext' {ContextSource
source :: ContextSource
$sel:source:CreateContext' :: CreateContext -> ContextSource
source} -> ContextSource
source) (\s :: CreateContext
s@CreateContext' {} ContextSource
a -> CreateContext
s {$sel:source:CreateContext' :: ContextSource
source = ContextSource
a} :: CreateContext)
createContext_contextType :: Lens.Lens' CreateContext Prelude.Text
createContext_contextType :: (Text -> f Text) -> CreateContext -> f CreateContext
createContext_contextType = (CreateContext -> Text)
-> (CreateContext -> Text -> CreateContext)
-> Lens CreateContext CreateContext Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContext' {Text
contextType :: Text
$sel:contextType:CreateContext' :: CreateContext -> Text
contextType} -> Text
contextType) (\s :: CreateContext
s@CreateContext' {} Text
a -> CreateContext
s {$sel:contextType:CreateContext' :: Text
contextType = Text
a} :: CreateContext)
instance Core.AWSRequest CreateContext where
type
AWSResponse CreateContext =
CreateContextResponse
request :: CreateContext -> Request CreateContext
request = Service -> CreateContext -> Request CreateContext
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateContext
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContext)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateContext))
-> Logger
-> Service
-> Proxy CreateContext
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContext)))
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 -> CreateContextResponse
CreateContextResponse'
(Maybe Text -> Int -> CreateContextResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateContextResponse)
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
"ContextArn")
Either String (Int -> CreateContextResponse)
-> Either String Int -> Either String CreateContextResponse
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 CreateContext
instance Prelude.NFData CreateContext
instance Core.ToHeaders CreateContext where
toHeaders :: CreateContext -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateContext -> 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
"SageMaker.CreateContext" :: 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 CreateContext where
toJSON :: CreateContext -> Value
toJSON CreateContext' {Maybe [Tag]
Maybe Text
Maybe (HashMap Text Text)
Text
ContextSource
contextType :: Text
source :: ContextSource
contextName :: Text
properties :: Maybe (HashMap Text Text)
tags :: Maybe [Tag]
description :: Maybe Text
$sel:contextType:CreateContext' :: CreateContext -> Text
$sel:source:CreateContext' :: CreateContext -> ContextSource
$sel:contextName:CreateContext' :: CreateContext -> Text
$sel:properties:CreateContext' :: CreateContext -> Maybe (HashMap Text Text)
$sel:tags:CreateContext' :: CreateContext -> Maybe [Tag]
$sel:description:CreateContext' :: CreateContext -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Description" 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
description,
(Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
(Text
"Properties" 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)
properties,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContextName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contextName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> ContextSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContextSource
source),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContextType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contextType)
]
)
instance Core.ToPath CreateContext where
toPath :: CreateContext -> ByteString
toPath = ByteString -> CreateContext -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateContext where
toQuery :: CreateContext -> QueryString
toQuery = QueryString -> CreateContext -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateContextResponse = CreateContextResponse'
{
CreateContextResponse -> Maybe Text
contextArn :: Prelude.Maybe Prelude.Text,
CreateContextResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateContextResponse -> CreateContextResponse -> Bool
(CreateContextResponse -> CreateContextResponse -> Bool)
-> (CreateContextResponse -> CreateContextResponse -> Bool)
-> Eq CreateContextResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContextResponse -> CreateContextResponse -> Bool
$c/= :: CreateContextResponse -> CreateContextResponse -> Bool
== :: CreateContextResponse -> CreateContextResponse -> Bool
$c== :: CreateContextResponse -> CreateContextResponse -> Bool
Prelude.Eq, ReadPrec [CreateContextResponse]
ReadPrec CreateContextResponse
Int -> ReadS CreateContextResponse
ReadS [CreateContextResponse]
(Int -> ReadS CreateContextResponse)
-> ReadS [CreateContextResponse]
-> ReadPrec CreateContextResponse
-> ReadPrec [CreateContextResponse]
-> Read CreateContextResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContextResponse]
$creadListPrec :: ReadPrec [CreateContextResponse]
readPrec :: ReadPrec CreateContextResponse
$creadPrec :: ReadPrec CreateContextResponse
readList :: ReadS [CreateContextResponse]
$creadList :: ReadS [CreateContextResponse]
readsPrec :: Int -> ReadS CreateContextResponse
$creadsPrec :: Int -> ReadS CreateContextResponse
Prelude.Read, Int -> CreateContextResponse -> ShowS
[CreateContextResponse] -> ShowS
CreateContextResponse -> String
(Int -> CreateContextResponse -> ShowS)
-> (CreateContextResponse -> String)
-> ([CreateContextResponse] -> ShowS)
-> Show CreateContextResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContextResponse] -> ShowS
$cshowList :: [CreateContextResponse] -> ShowS
show :: CreateContextResponse -> String
$cshow :: CreateContextResponse -> String
showsPrec :: Int -> CreateContextResponse -> ShowS
$cshowsPrec :: Int -> CreateContextResponse -> ShowS
Prelude.Show, (forall x. CreateContextResponse -> Rep CreateContextResponse x)
-> (forall x. Rep CreateContextResponse x -> CreateContextResponse)
-> Generic CreateContextResponse
forall x. Rep CreateContextResponse x -> CreateContextResponse
forall x. CreateContextResponse -> Rep CreateContextResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContextResponse x -> CreateContextResponse
$cfrom :: forall x. CreateContextResponse -> Rep CreateContextResponse x
Prelude.Generic)
newCreateContextResponse ::
Prelude.Int ->
CreateContextResponse
newCreateContextResponse :: Int -> CreateContextResponse
newCreateContextResponse Int
pHttpStatus_ =
CreateContextResponse' :: Maybe Text -> Int -> CreateContextResponse
CreateContextResponse'
{ $sel:contextArn:CreateContextResponse' :: Maybe Text
contextArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateContextResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createContextResponse_contextArn :: Lens.Lens' CreateContextResponse (Prelude.Maybe Prelude.Text)
createContextResponse_contextArn :: (Maybe Text -> f (Maybe Text))
-> CreateContextResponse -> f CreateContextResponse
createContextResponse_contextArn = (CreateContextResponse -> Maybe Text)
-> (CreateContextResponse -> Maybe Text -> CreateContextResponse)
-> Lens
CreateContextResponse
CreateContextResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContextResponse' {Maybe Text
contextArn :: Maybe Text
$sel:contextArn:CreateContextResponse' :: CreateContextResponse -> Maybe Text
contextArn} -> Maybe Text
contextArn) (\s :: CreateContextResponse
s@CreateContextResponse' {} Maybe Text
a -> CreateContextResponse
s {$sel:contextArn:CreateContextResponse' :: Maybe Text
contextArn = Maybe Text
a} :: CreateContextResponse)
createContextResponse_httpStatus :: Lens.Lens' CreateContextResponse Prelude.Int
createContextResponse_httpStatus :: (Int -> f Int) -> CreateContextResponse -> f CreateContextResponse
createContextResponse_httpStatus = (CreateContextResponse -> Int)
-> (CreateContextResponse -> Int -> CreateContextResponse)
-> Lens CreateContextResponse CreateContextResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContextResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContextResponse' :: CreateContextResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateContextResponse
s@CreateContextResponse' {} Int
a -> CreateContextResponse
s {$sel:httpStatus:CreateContextResponse' :: Int
httpStatus = Int
a} :: CreateContextResponse)
instance Prelude.NFData CreateContextResponse