{-# 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.DisassociateTrialComponent
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a trial component from a trial. This doesn\'t effect other
-- trials the component is associated with. Before you can delete a
-- component, you must disassociate the component from all trials it is
-- associated with. To associate a trial component with a trial, call the
-- AssociateTrialComponent API.
--
-- To get a list of the trials a component is associated with, use the
-- Search API. Specify @ExperimentTrialComponent@ for the @Resource@
-- parameter. The list appears in the response under
-- @Results.TrialComponent.Parents@.
module Amazonka.SageMaker.DisassociateTrialComponent
  ( -- * Creating a Request
    DisassociateTrialComponent (..),
    newDisassociateTrialComponent,

    -- * Request Lenses
    disassociateTrialComponent_trialComponentName,
    disassociateTrialComponent_trialName,

    -- * Destructuring the Response
    DisassociateTrialComponentResponse (..),
    newDisassociateTrialComponentResponse,

    -- * Response Lenses
    disassociateTrialComponentResponse_trialArn,
    disassociateTrialComponentResponse_trialComponentArn,
    disassociateTrialComponentResponse_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:/ 'newDisassociateTrialComponent' smart constructor.
data DisassociateTrialComponent = DisassociateTrialComponent'
  { -- | The name of the component to disassociate from the trial.
    DisassociateTrialComponent -> Text
trialComponentName :: Prelude.Text,
    -- | The name of the trial to disassociate from.
    DisassociateTrialComponent -> Text
trialName :: Prelude.Text
  }
  deriving (DisassociateTrialComponent -> DisassociateTrialComponent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateTrialComponent -> DisassociateTrialComponent -> Bool
$c/= :: DisassociateTrialComponent -> DisassociateTrialComponent -> Bool
== :: DisassociateTrialComponent -> DisassociateTrialComponent -> Bool
$c== :: DisassociateTrialComponent -> DisassociateTrialComponent -> Bool
Prelude.Eq, ReadPrec [DisassociateTrialComponent]
ReadPrec DisassociateTrialComponent
Int -> ReadS DisassociateTrialComponent
ReadS [DisassociateTrialComponent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateTrialComponent]
$creadListPrec :: ReadPrec [DisassociateTrialComponent]
readPrec :: ReadPrec DisassociateTrialComponent
$creadPrec :: ReadPrec DisassociateTrialComponent
readList :: ReadS [DisassociateTrialComponent]
$creadList :: ReadS [DisassociateTrialComponent]
readsPrec :: Int -> ReadS DisassociateTrialComponent
$creadsPrec :: Int -> ReadS DisassociateTrialComponent
Prelude.Read, Int -> DisassociateTrialComponent -> ShowS
[DisassociateTrialComponent] -> ShowS
DisassociateTrialComponent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateTrialComponent] -> ShowS
$cshowList :: [DisassociateTrialComponent] -> ShowS
show :: DisassociateTrialComponent -> String
$cshow :: DisassociateTrialComponent -> String
showsPrec :: Int -> DisassociateTrialComponent -> ShowS
$cshowsPrec :: Int -> DisassociateTrialComponent -> ShowS
Prelude.Show, forall x.
Rep DisassociateTrialComponent x -> DisassociateTrialComponent
forall x.
DisassociateTrialComponent -> Rep DisassociateTrialComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateTrialComponent x -> DisassociateTrialComponent
$cfrom :: forall x.
DisassociateTrialComponent -> Rep DisassociateTrialComponent x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateTrialComponent' 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', 'disassociateTrialComponent_trialComponentName' - The name of the component to disassociate from the trial.
--
-- 'trialName', 'disassociateTrialComponent_trialName' - The name of the trial to disassociate from.
newDisassociateTrialComponent ::
  -- | 'trialComponentName'
  Prelude.Text ->
  -- | 'trialName'
  Prelude.Text ->
  DisassociateTrialComponent
newDisassociateTrialComponent :: Text -> Text -> DisassociateTrialComponent
newDisassociateTrialComponent
  Text
pTrialComponentName_
  Text
pTrialName_ =
    DisassociateTrialComponent'
      { $sel:trialComponentName:DisassociateTrialComponent' :: Text
trialComponentName =
          Text
pTrialComponentName_,
        $sel:trialName:DisassociateTrialComponent' :: Text
trialName = Text
pTrialName_
      }

-- | The name of the component to disassociate from the trial.
disassociateTrialComponent_trialComponentName :: Lens.Lens' DisassociateTrialComponent Prelude.Text
disassociateTrialComponent_trialComponentName :: Lens' DisassociateTrialComponent Text
disassociateTrialComponent_trialComponentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateTrialComponent' {Text
trialComponentName :: Text
$sel:trialComponentName:DisassociateTrialComponent' :: DisassociateTrialComponent -> Text
trialComponentName} -> Text
trialComponentName) (\s :: DisassociateTrialComponent
s@DisassociateTrialComponent' {} Text
a -> DisassociateTrialComponent
s {$sel:trialComponentName:DisassociateTrialComponent' :: Text
trialComponentName = Text
a} :: DisassociateTrialComponent)

-- | The name of the trial to disassociate from.
disassociateTrialComponent_trialName :: Lens.Lens' DisassociateTrialComponent Prelude.Text
disassociateTrialComponent_trialName :: Lens' DisassociateTrialComponent Text
disassociateTrialComponent_trialName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateTrialComponent' {Text
trialName :: Text
$sel:trialName:DisassociateTrialComponent' :: DisassociateTrialComponent -> Text
trialName} -> Text
trialName) (\s :: DisassociateTrialComponent
s@DisassociateTrialComponent' {} Text
a -> DisassociateTrialComponent
s {$sel:trialName:DisassociateTrialComponent' :: Text
trialName = Text
a} :: DisassociateTrialComponent)

instance Core.AWSRequest DisassociateTrialComponent where
  type
    AWSResponse DisassociateTrialComponent =
      DisassociateTrialComponentResponse
  request :: (Service -> Service)
-> DisassociateTrialComponent -> Request DisassociateTrialComponent
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 DisassociateTrialComponent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateTrialComponent)))
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 -> DisassociateTrialComponentResponse
DisassociateTrialComponentResponse'
            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 DisassociateTrialComponent where
  hashWithSalt :: Int -> DisassociateTrialComponent -> Int
hashWithSalt Int
_salt DisassociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:DisassociateTrialComponent' :: DisassociateTrialComponent -> Text
$sel:trialComponentName:DisassociateTrialComponent' :: DisassociateTrialComponent -> 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 DisassociateTrialComponent where
  rnf :: DisassociateTrialComponent -> ()
rnf DisassociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:DisassociateTrialComponent' :: DisassociateTrialComponent -> Text
$sel:trialComponentName:DisassociateTrialComponent' :: DisassociateTrialComponent -> 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 DisassociateTrialComponent where
  toHeaders :: DisassociateTrialComponent -> 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.DisassociateTrialComponent" ::
                          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 DisassociateTrialComponent where
  toJSON :: DisassociateTrialComponent -> Value
toJSON DisassociateTrialComponent' {Text
trialName :: Text
trialComponentName :: Text
$sel:trialName:DisassociateTrialComponent' :: DisassociateTrialComponent -> Text
$sel:trialComponentName:DisassociateTrialComponent' :: DisassociateTrialComponent -> 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 DisassociateTrialComponent where
  toPath :: DisassociateTrialComponent -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DisassociateTrialComponentResponse' 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', 'disassociateTrialComponentResponse_trialArn' - The Amazon Resource Name (ARN) of the trial.
--
-- 'trialComponentArn', 'disassociateTrialComponentResponse_trialComponentArn' - The Amazon Resource Name (ARN) of the trial component.
--
-- 'httpStatus', 'disassociateTrialComponentResponse_httpStatus' - The response's http status code.
newDisassociateTrialComponentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateTrialComponentResponse
newDisassociateTrialComponentResponse :: Int -> DisassociateTrialComponentResponse
newDisassociateTrialComponentResponse Int
pHttpStatus_ =
  DisassociateTrialComponentResponse'
    { $sel:trialArn:DisassociateTrialComponentResponse' :: Maybe Text
trialArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:trialComponentArn:DisassociateTrialComponentResponse' :: Maybe Text
trialComponentArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateTrialComponentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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

instance
  Prelude.NFData
    DisassociateTrialComponentResponse
  where
  rnf :: DisassociateTrialComponentResponse -> ()
rnf DisassociateTrialComponentResponse' {Int
Maybe Text
httpStatus :: Int
trialComponentArn :: Maybe Text
trialArn :: Maybe Text
$sel:httpStatus:DisassociateTrialComponentResponse' :: DisassociateTrialComponentResponse -> Int
$sel:trialComponentArn:DisassociateTrialComponentResponse' :: DisassociateTrialComponentResponse -> Maybe Text
$sel:trialArn:DisassociateTrialComponentResponse' :: DisassociateTrialComponentResponse -> 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