{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $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 :: Lens' AssociateTrialComponent Text
associateTrialComponent_trialComponentName = 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 :: Lens' AssociateTrialComponent Text
associateTrialComponent_trialName = 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 :: (Service -> Service)
-> AssociateTrialComponent -> Request AssociateTrialComponent
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateTrialComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrialComponent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TrialArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TrialComponentArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AssociateTrialComponent where
  hashWithSalt :: Int -> AssociateTrialComponent -> Int
hashWithSalt Int
_salt AssociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
$sel:trialComponentName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trialComponentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
trialName

instance Prelude.NFData AssociateTrialComponent where
  rnf :: AssociateTrialComponent -> ()
rnf AssociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
$sel:trialComponentName:AssociateTrialComponent' :: AssociateTrialComponent -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
trialComponentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trialName

instance Data.ToHeaders AssociateTrialComponent where
  toHeaders :: AssociateTrialComponent -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"SageMaker.AssociateTrialComponent" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"TrialComponentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
trialComponentName),
            forall a. a -> Maybe a
Prelude.Just (Key
"TrialName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
trialName)
          ]
      )

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

instance Data.ToQuery AssociateTrialComponent where
  toQuery :: AssociateTrialComponent -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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 Amazon Resource Name (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
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]
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
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.
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 Amazon Resource Name (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'
    { $sel:trialArn:AssociateTrialComponentResponse' :: Maybe Text
trialArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:trialComponentArn:AssociateTrialComponentResponse' :: Maybe Text
trialComponentArn = 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 :: Lens' AssociateTrialComponentResponse (Maybe Text)
associateTrialComponentResponse_trialArn = 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 Amazon Resource Name (ARN) of the trial component.
associateTrialComponentResponse_trialComponentArn :: Lens.Lens' AssociateTrialComponentResponse (Prelude.Maybe Prelude.Text)
associateTrialComponentResponse_trialComponentArn :: Lens' AssociateTrialComponentResponse (Maybe Text)
associateTrialComponentResponse_trialComponentArn = 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 :: Lens' AssociateTrialComponentResponse Int
associateTrialComponentResponse_httpStatus = 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
  where
  rnf :: AssociateTrialComponentResponse -> ()
rnf AssociateTrialComponentResponse' {Int
Maybe Text
httpStatus :: Int
trialComponentArn :: Maybe Text
trialArn :: Maybe Text
$sel:httpStatus:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Int
$sel:trialComponentArn:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Maybe Text
$sel:trialArn:AssociateTrialComponentResponse' :: AssociateTrialComponentResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
trialArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
trialComponentArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus