{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SageMaker.AssociateTrialComponent
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a trial component with a trial. A trial component can be
-- associated with multiple trials. To disassociate a trial component from
-- a trial, call the DisassociateTrialComponent API.
module Amazonka.SageMaker.AssociateTrialComponent
  ( -- * Creating a Request
    AssociateTrialComponent (..),
    newAssociateTrialComponent,

    -- * Request Lenses
    associateTrialComponent_trialComponentName,
    associateTrialComponent_trialName,

    -- * Destructuring the Response
    AssociateTrialComponentResponse (..),
    newAssociateTrialComponentResponse,

    -- * Response Lenses
    associateTrialComponentResponse_trialArn,
    associateTrialComponentResponse_trialComponentArn,
    associateTrialComponentResponse_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

-- | /See:/ 'newAssociateTrialComponent' smart constructor.
data AssociateTrialComponent = AssociateTrialComponent'
  { -- | The name of the component to associated with the trial.
    AssociateTrialComponent -> Text
trialComponentName :: Prelude.Text,
    -- | The name of the trial to associate with.
    AssociateTrialComponent -> Text
trialName :: Prelude.Text
  }
  deriving (AssociateTrialComponent -> AssociateTrialComponent -> Bool
(AssociateTrialComponent -> AssociateTrialComponent -> Bool)
-> (AssociateTrialComponent -> AssociateTrialComponent -> Bool)
-> Eq AssociateTrialComponent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateTrialComponent -> AssociateTrialComponent -> Bool
$c/= :: AssociateTrialComponent -> AssociateTrialComponent -> Bool
== :: AssociateTrialComponent -> AssociateTrialComponent -> Bool
$c== :: AssociateTrialComponent -> AssociateTrialComponent -> Bool
Prelude.Eq, ReadPrec [AssociateTrialComponent]
ReadPrec AssociateTrialComponent
Int -> ReadS AssociateTrialComponent
ReadS [AssociateTrialComponent]
(Int -> ReadS AssociateTrialComponent)
-> ReadS [AssociateTrialComponent]
-> ReadPrec AssociateTrialComponent
-> ReadPrec [AssociateTrialComponent]
-> Read AssociateTrialComponent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateTrialComponent]
$creadListPrec :: ReadPrec [AssociateTrialComponent]
readPrec :: ReadPrec AssociateTrialComponent
$creadPrec :: ReadPrec AssociateTrialComponent
readList :: ReadS [AssociateTrialComponent]
$creadList :: ReadS [AssociateTrialComponent]
readsPrec :: Int -> ReadS AssociateTrialComponent
$creadsPrec :: Int -> ReadS AssociateTrialComponent
Prelude.Read, Int -> AssociateTrialComponent -> ShowS
[AssociateTrialComponent] -> ShowS
AssociateTrialComponent -> String
(Int -> AssociateTrialComponent -> ShowS)
-> (AssociateTrialComponent -> String)
-> ([AssociateTrialComponent] -> ShowS)
-> Show AssociateTrialComponent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateTrialComponent] -> ShowS
$cshowList :: [AssociateTrialComponent] -> ShowS
show :: AssociateTrialComponent -> String
$cshow :: AssociateTrialComponent -> String
showsPrec :: Int -> AssociateTrialComponent -> ShowS
$cshowsPrec :: Int -> AssociateTrialComponent -> ShowS
Prelude.Show, (forall x.
 AssociateTrialComponent -> Rep AssociateTrialComponent x)
-> (forall x.
    Rep AssociateTrialComponent x -> AssociateTrialComponent)
-> Generic AssociateTrialComponent
forall x. Rep AssociateTrialComponent x -> AssociateTrialComponent
forall x. AssociateTrialComponent -> Rep AssociateTrialComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateTrialComponent x -> AssociateTrialComponent
$cfrom :: forall x. AssociateTrialComponent -> Rep AssociateTrialComponent x
Prelude.Generic)

-- |
-- Create a value of 'AssociateTrialComponent' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'trialComponentName', 'associateTrialComponent_trialComponentName' - The name of the component to associated with the trial.
--
-- 'trialName', 'associateTrialComponent_trialName' - The name of the trial to associate with.
newAssociateTrialComponent ::
  -- | 'trialComponentName'
  Prelude.Text ->
  -- | 'trialName'
  Prelude.Text ->
  AssociateTrialComponent
newAssociateTrialComponent :: Text -> Text -> AssociateTrialComponent
newAssociateTrialComponent
  Text
pTrialComponentName_
  Text
pTrialName_ =
    AssociateTrialComponent' :: Text -> Text -> AssociateTrialComponent
AssociateTrialComponent'
      { $sel:trialComponentName:AssociateTrialComponent' :: Text
trialComponentName =
          Text
pTrialComponentName_,
        $sel:trialName:AssociateTrialComponent' :: Text
trialName = Text
pTrialName_
      }

-- | The name of the component to associated with the trial.
associateTrialComponent_trialComponentName :: Lens.Lens' AssociateTrialComponent Prelude.Text
associateTrialComponent_trialComponentName :: (Text -> f Text)
-> AssociateTrialComponent -> f AssociateTrialComponent
associateTrialComponent_trialComponentName = (AssociateTrialComponent -> Text)
-> (AssociateTrialComponent -> Text -> AssociateTrialComponent)
-> Lens AssociateTrialComponent AssociateTrialComponent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrialComponent' {Text
trialComponentName :: Text
$sel:trialComponentName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
trialComponentName} -> Text
trialComponentName) (\s :: AssociateTrialComponent
s@AssociateTrialComponent' {} Text
a -> AssociateTrialComponent
s {$sel:trialComponentName:AssociateTrialComponent' :: Text
trialComponentName = Text
a} :: AssociateTrialComponent)

-- | The name of the trial to associate with.
associateTrialComponent_trialName :: Lens.Lens' AssociateTrialComponent Prelude.Text
associateTrialComponent_trialName :: (Text -> f Text)
-> AssociateTrialComponent -> f AssociateTrialComponent
associateTrialComponent_trialName = (AssociateTrialComponent -> Text)
-> (AssociateTrialComponent -> Text -> AssociateTrialComponent)
-> Lens AssociateTrialComponent AssociateTrialComponent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrialComponent' {Text
trialName :: Text
$sel:trialName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
trialName} -> Text
trialName) (\s :: AssociateTrialComponent
s@AssociateTrialComponent' {} Text
a -> AssociateTrialComponent
s {$sel:trialName:AssociateTrialComponent' :: Text
trialName = Text
a} :: AssociateTrialComponent)

instance Core.AWSRequest AssociateTrialComponent where
  type
    AWSResponse AssociateTrialComponent =
      AssociateTrialComponentResponse
  request :: AssociateTrialComponent -> Request AssociateTrialComponent
request = Service
-> AssociateTrialComponent -> Request AssociateTrialComponent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateTrialComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrialComponent)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AssociateTrialComponent))
-> Logger
-> Service
-> Proxy AssociateTrialComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrialComponent)))
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 -> Maybe Text -> Int -> AssociateTrialComponentResponse
AssociateTrialComponentResponse'
            (Maybe Text
 -> Maybe Text -> Int -> AssociateTrialComponentResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> AssociateTrialComponentResponse)
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
"TrialArn")
            Either
  String (Maybe Text -> Int -> AssociateTrialComponentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AssociateTrialComponentResponse)
forall (f :: * -> *) a b. Applicative f => 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
"TrialComponentArn")
            Either String (Int -> AssociateTrialComponentResponse)
-> Either String Int
-> Either String AssociateTrialComponentResponse
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 AssociateTrialComponent

instance Prelude.NFData AssociateTrialComponent

instance Core.ToHeaders AssociateTrialComponent where
  toHeaders :: AssociateTrialComponent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateTrialComponent -> 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.AssociateTrialComponent" ::
                          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 AssociateTrialComponent where
  toJSON :: AssociateTrialComponent -> Value
toJSON AssociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
$sel:trialComponentName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TrialComponentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
trialComponentName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TrialName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
trialName)
          ]
      )

instance Core.ToPath AssociateTrialComponent where
  toPath :: AssociateTrialComponent -> ByteString
toPath = ByteString -> AssociateTrialComponent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery AssociateTrialComponent where
  toQuery :: AssociateTrialComponent -> QueryString
toQuery = QueryString -> AssociateTrialComponent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newAssociateTrialComponentResponse' smart constructor.
data AssociateTrialComponentResponse = AssociateTrialComponentResponse'
  { -- | The Amazon Resource Name (ARN) of the trial.
    AssociateTrialComponentResponse -> Maybe Text
trialArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the trial component.
    AssociateTrialComponentResponse -> Maybe Text
trialComponentArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AssociateTrialComponentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AssociateTrialComponentResponse
-> AssociateTrialComponentResponse -> Bool
(AssociateTrialComponentResponse
 -> AssociateTrialComponentResponse -> Bool)
-> (AssociateTrialComponentResponse
    -> AssociateTrialComponentResponse -> Bool)
-> Eq AssociateTrialComponentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateTrialComponentResponse
-> AssociateTrialComponentResponse -> Bool
$c/= :: AssociateTrialComponentResponse
-> AssociateTrialComponentResponse -> Bool
== :: AssociateTrialComponentResponse
-> AssociateTrialComponentResponse -> Bool
$c== :: AssociateTrialComponentResponse
-> AssociateTrialComponentResponse -> Bool
Prelude.Eq, ReadPrec [AssociateTrialComponentResponse]
ReadPrec AssociateTrialComponentResponse
Int -> ReadS AssociateTrialComponentResponse
ReadS [AssociateTrialComponentResponse]
(Int -> ReadS AssociateTrialComponentResponse)
-> ReadS [AssociateTrialComponentResponse]
-> ReadPrec AssociateTrialComponentResponse
-> ReadPrec [AssociateTrialComponentResponse]
-> Read AssociateTrialComponentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateTrialComponentResponse]
$creadListPrec :: ReadPrec [AssociateTrialComponentResponse]
readPrec :: ReadPrec AssociateTrialComponentResponse
$creadPrec :: ReadPrec AssociateTrialComponentResponse
readList :: ReadS [AssociateTrialComponentResponse]
$creadList :: ReadS [AssociateTrialComponentResponse]
readsPrec :: Int -> ReadS AssociateTrialComponentResponse
$creadsPrec :: Int -> ReadS AssociateTrialComponentResponse
Prelude.Read, Int -> AssociateTrialComponentResponse -> ShowS
[AssociateTrialComponentResponse] -> ShowS
AssociateTrialComponentResponse -> String
(Int -> AssociateTrialComponentResponse -> ShowS)
-> (AssociateTrialComponentResponse -> String)
-> ([AssociateTrialComponentResponse] -> ShowS)
-> Show AssociateTrialComponentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateTrialComponentResponse] -> ShowS
$cshowList :: [AssociateTrialComponentResponse] -> ShowS
show :: AssociateTrialComponentResponse -> String
$cshow :: AssociateTrialComponentResponse -> String
showsPrec :: Int -> AssociateTrialComponentResponse -> ShowS
$cshowsPrec :: Int -> AssociateTrialComponentResponse -> ShowS
Prelude.Show, (forall x.
 AssociateTrialComponentResponse
 -> Rep AssociateTrialComponentResponse x)
-> (forall x.
    Rep AssociateTrialComponentResponse x
    -> AssociateTrialComponentResponse)
-> Generic AssociateTrialComponentResponse
forall x.
Rep AssociateTrialComponentResponse x
-> AssociateTrialComponentResponse
forall x.
AssociateTrialComponentResponse
-> Rep AssociateTrialComponentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateTrialComponentResponse x
-> AssociateTrialComponentResponse
$cfrom :: forall x.
AssociateTrialComponentResponse
-> Rep AssociateTrialComponentResponse x
Prelude.Generic)

-- |
-- Create a value of 'AssociateTrialComponentResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'trialArn', 'associateTrialComponentResponse_trialArn' - The Amazon Resource Name (ARN) of the trial.
--
-- 'trialComponentArn', 'associateTrialComponentResponse_trialComponentArn' - The ARN of the trial component.
--
-- 'httpStatus', 'associateTrialComponentResponse_httpStatus' - The response's http status code.
newAssociateTrialComponentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateTrialComponentResponse
newAssociateTrialComponentResponse :: Int -> AssociateTrialComponentResponse
newAssociateTrialComponentResponse Int
pHttpStatus_ =
  AssociateTrialComponentResponse' :: Maybe Text -> Maybe Text -> Int -> AssociateTrialComponentResponse
AssociateTrialComponentResponse'
    { $sel:trialArn:AssociateTrialComponentResponse' :: Maybe Text
trialArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:trialComponentArn:AssociateTrialComponentResponse' :: Maybe Text
trialComponentArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AssociateTrialComponentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the trial.
associateTrialComponentResponse_trialArn :: Lens.Lens' AssociateTrialComponentResponse (Prelude.Maybe Prelude.Text)
associateTrialComponentResponse_trialArn :: (Maybe Text -> f (Maybe Text))
-> AssociateTrialComponentResponse
-> f AssociateTrialComponentResponse
associateTrialComponentResponse_trialArn = (AssociateTrialComponentResponse -> Maybe Text)
-> (AssociateTrialComponentResponse
    -> Maybe Text -> AssociateTrialComponentResponse)
-> Lens
     AssociateTrialComponentResponse
     AssociateTrialComponentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrialComponentResponse' {Maybe Text
trialArn :: Maybe Text
$sel:trialArn:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Maybe Text
trialArn} -> Maybe Text
trialArn) (\s :: AssociateTrialComponentResponse
s@AssociateTrialComponentResponse' {} Maybe Text
a -> AssociateTrialComponentResponse
s {$sel:trialArn:AssociateTrialComponentResponse' :: Maybe Text
trialArn = Maybe Text
a} :: AssociateTrialComponentResponse)

-- | The ARN of the trial component.
associateTrialComponentResponse_trialComponentArn :: Lens.Lens' AssociateTrialComponentResponse (Prelude.Maybe Prelude.Text)
associateTrialComponentResponse_trialComponentArn :: (Maybe Text -> f (Maybe Text))
-> AssociateTrialComponentResponse
-> f AssociateTrialComponentResponse
associateTrialComponentResponse_trialComponentArn = (AssociateTrialComponentResponse -> Maybe Text)
-> (AssociateTrialComponentResponse
    -> Maybe Text -> AssociateTrialComponentResponse)
-> Lens
     AssociateTrialComponentResponse
     AssociateTrialComponentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrialComponentResponse' {Maybe Text
trialComponentArn :: Maybe Text
$sel:trialComponentArn:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Maybe Text
trialComponentArn} -> Maybe Text
trialComponentArn) (\s :: AssociateTrialComponentResponse
s@AssociateTrialComponentResponse' {} Maybe Text
a -> AssociateTrialComponentResponse
s {$sel:trialComponentArn:AssociateTrialComponentResponse' :: Maybe Text
trialComponentArn = Maybe Text
a} :: AssociateTrialComponentResponse)

-- | The response's http status code.
associateTrialComponentResponse_httpStatus :: Lens.Lens' AssociateTrialComponentResponse Prelude.Int
associateTrialComponentResponse_httpStatus :: (Int -> f Int)
-> AssociateTrialComponentResponse
-> f AssociateTrialComponentResponse
associateTrialComponentResponse_httpStatus = (AssociateTrialComponentResponse -> Int)
-> (AssociateTrialComponentResponse
    -> Int -> AssociateTrialComponentResponse)
-> Lens
     AssociateTrialComponentResponse
     AssociateTrialComponentResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrialComponentResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AssociateTrialComponentResponse
s@AssociateTrialComponentResponse' {} Int
a -> AssociateTrialComponentResponse
s {$sel:httpStatus:AssociateTrialComponentResponse' :: Int
httpStatus = Int
a} :: AssociateTrialComponentResponse)

instance
  Prelude.NFData
    AssociateTrialComponentResponse