{-# 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.Forecast.UpdateDatasetGroup
-- 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)
--
-- Replaces the datasets in a dataset group with the specified datasets.
--
-- The @Status@ of the dataset group must be @ACTIVE@ before you can use
-- the dataset group to create a predictor. Use the DescribeDatasetGroup
-- operation to get the status.
module Amazonka.Forecast.UpdateDatasetGroup
  ( -- * Creating a Request
    UpdateDatasetGroup (..),
    newUpdateDatasetGroup,

    -- * Request Lenses
    updateDatasetGroup_datasetGroupArn,
    updateDatasetGroup_datasetArns,

    -- * Destructuring the Response
    UpdateDatasetGroupResponse (..),
    newUpdateDatasetGroupResponse,

    -- * Response Lenses
    updateDatasetGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateDatasetGroup' smart constructor.
data UpdateDatasetGroup = UpdateDatasetGroup'
  { -- | The ARN of the dataset group.
    UpdateDatasetGroup -> Text
datasetGroupArn :: Prelude.Text,
    -- | An array of the Amazon Resource Names (ARNs) of the datasets to add to
    -- the dataset group.
    UpdateDatasetGroup -> [Text]
datasetArns :: [Prelude.Text]
  }
  deriving (UpdateDatasetGroup -> UpdateDatasetGroup -> Bool
(UpdateDatasetGroup -> UpdateDatasetGroup -> Bool)
-> (UpdateDatasetGroup -> UpdateDatasetGroup -> Bool)
-> Eq UpdateDatasetGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDatasetGroup -> UpdateDatasetGroup -> Bool
$c/= :: UpdateDatasetGroup -> UpdateDatasetGroup -> Bool
== :: UpdateDatasetGroup -> UpdateDatasetGroup -> Bool
$c== :: UpdateDatasetGroup -> UpdateDatasetGroup -> Bool
Prelude.Eq, ReadPrec [UpdateDatasetGroup]
ReadPrec UpdateDatasetGroup
Int -> ReadS UpdateDatasetGroup
ReadS [UpdateDatasetGroup]
(Int -> ReadS UpdateDatasetGroup)
-> ReadS [UpdateDatasetGroup]
-> ReadPrec UpdateDatasetGroup
-> ReadPrec [UpdateDatasetGroup]
-> Read UpdateDatasetGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDatasetGroup]
$creadListPrec :: ReadPrec [UpdateDatasetGroup]
readPrec :: ReadPrec UpdateDatasetGroup
$creadPrec :: ReadPrec UpdateDatasetGroup
readList :: ReadS [UpdateDatasetGroup]
$creadList :: ReadS [UpdateDatasetGroup]
readsPrec :: Int -> ReadS UpdateDatasetGroup
$creadsPrec :: Int -> ReadS UpdateDatasetGroup
Prelude.Read, Int -> UpdateDatasetGroup -> ShowS
[UpdateDatasetGroup] -> ShowS
UpdateDatasetGroup -> String
(Int -> UpdateDatasetGroup -> ShowS)
-> (UpdateDatasetGroup -> String)
-> ([UpdateDatasetGroup] -> ShowS)
-> Show UpdateDatasetGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDatasetGroup] -> ShowS
$cshowList :: [UpdateDatasetGroup] -> ShowS
show :: UpdateDatasetGroup -> String
$cshow :: UpdateDatasetGroup -> String
showsPrec :: Int -> UpdateDatasetGroup -> ShowS
$cshowsPrec :: Int -> UpdateDatasetGroup -> ShowS
Prelude.Show, (forall x. UpdateDatasetGroup -> Rep UpdateDatasetGroup x)
-> (forall x. Rep UpdateDatasetGroup x -> UpdateDatasetGroup)
-> Generic UpdateDatasetGroup
forall x. Rep UpdateDatasetGroup x -> UpdateDatasetGroup
forall x. UpdateDatasetGroup -> Rep UpdateDatasetGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDatasetGroup x -> UpdateDatasetGroup
$cfrom :: forall x. UpdateDatasetGroup -> Rep UpdateDatasetGroup x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDatasetGroup' 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:
--
-- 'datasetGroupArn', 'updateDatasetGroup_datasetGroupArn' - The ARN of the dataset group.
--
-- 'datasetArns', 'updateDatasetGroup_datasetArns' - An array of the Amazon Resource Names (ARNs) of the datasets to add to
-- the dataset group.
newUpdateDatasetGroup ::
  -- | 'datasetGroupArn'
  Prelude.Text ->
  UpdateDatasetGroup
newUpdateDatasetGroup :: Text -> UpdateDatasetGroup
newUpdateDatasetGroup Text
pDatasetGroupArn_ =
  UpdateDatasetGroup' :: Text -> [Text] -> UpdateDatasetGroup
UpdateDatasetGroup'
    { $sel:datasetGroupArn:UpdateDatasetGroup' :: Text
datasetGroupArn =
        Text
pDatasetGroupArn_,
      $sel:datasetArns:UpdateDatasetGroup' :: [Text]
datasetArns = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ARN of the dataset group.
updateDatasetGroup_datasetGroupArn :: Lens.Lens' UpdateDatasetGroup Prelude.Text
updateDatasetGroup_datasetGroupArn :: (Text -> f Text) -> UpdateDatasetGroup -> f UpdateDatasetGroup
updateDatasetGroup_datasetGroupArn = (UpdateDatasetGroup -> Text)
-> (UpdateDatasetGroup -> Text -> UpdateDatasetGroup)
-> Lens UpdateDatasetGroup UpdateDatasetGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatasetGroup' {Text
datasetGroupArn :: Text
$sel:datasetGroupArn:UpdateDatasetGroup' :: UpdateDatasetGroup -> Text
datasetGroupArn} -> Text
datasetGroupArn) (\s :: UpdateDatasetGroup
s@UpdateDatasetGroup' {} Text
a -> UpdateDatasetGroup
s {$sel:datasetGroupArn:UpdateDatasetGroup' :: Text
datasetGroupArn = Text
a} :: UpdateDatasetGroup)

-- | An array of the Amazon Resource Names (ARNs) of the datasets to add to
-- the dataset group.
updateDatasetGroup_datasetArns :: Lens.Lens' UpdateDatasetGroup [Prelude.Text]
updateDatasetGroup_datasetArns :: ([Text] -> f [Text]) -> UpdateDatasetGroup -> f UpdateDatasetGroup
updateDatasetGroup_datasetArns = (UpdateDatasetGroup -> [Text])
-> (UpdateDatasetGroup -> [Text] -> UpdateDatasetGroup)
-> Lens UpdateDatasetGroup UpdateDatasetGroup [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatasetGroup' {[Text]
datasetArns :: [Text]
$sel:datasetArns:UpdateDatasetGroup' :: UpdateDatasetGroup -> [Text]
datasetArns} -> [Text]
datasetArns) (\s :: UpdateDatasetGroup
s@UpdateDatasetGroup' {} [Text]
a -> UpdateDatasetGroup
s {$sel:datasetArns:UpdateDatasetGroup' :: [Text]
datasetArns = [Text]
a} :: UpdateDatasetGroup) (([Text] -> f [Text])
 -> UpdateDatasetGroup -> f UpdateDatasetGroup)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> UpdateDatasetGroup
-> f UpdateDatasetGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateDatasetGroup where
  type
    AWSResponse UpdateDatasetGroup =
      UpdateDatasetGroupResponse
  request :: UpdateDatasetGroup -> Request UpdateDatasetGroup
request = Service -> UpdateDatasetGroup -> Request UpdateDatasetGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDatasetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDatasetGroup)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateDatasetGroup))
-> Logger
-> Service
-> Proxy UpdateDatasetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDatasetGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateDatasetGroupResponse
UpdateDatasetGroupResponse'
            (Int -> UpdateDatasetGroupResponse)
-> Either String Int -> Either String UpdateDatasetGroupResponse
forall (f :: * -> *) a b. Functor 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 UpdateDatasetGroup

instance Prelude.NFData UpdateDatasetGroup

instance Core.ToHeaders UpdateDatasetGroup where
  toHeaders :: UpdateDatasetGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDatasetGroup -> 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
"AmazonForecast.UpdateDatasetGroup" ::
                          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 UpdateDatasetGroup where
  toJSON :: UpdateDatasetGroup -> Value
toJSON UpdateDatasetGroup' {[Text]
Text
datasetArns :: [Text]
datasetGroupArn :: Text
$sel:datasetArns:UpdateDatasetGroup' :: UpdateDatasetGroup -> [Text]
$sel:datasetGroupArn:UpdateDatasetGroup' :: UpdateDatasetGroup -> 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
"DatasetGroupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
datasetGroupArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatasetArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
datasetArns)
          ]
      )

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

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

-- | /See:/ 'newUpdateDatasetGroupResponse' smart constructor.
data UpdateDatasetGroupResponse = UpdateDatasetGroupResponse'
  { -- | The response's http status code.
    UpdateDatasetGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool
(UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool)
-> (UpdateDatasetGroupResponse
    -> UpdateDatasetGroupResponse -> Bool)
-> Eq UpdateDatasetGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool
$c/= :: UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool
== :: UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool
$c== :: UpdateDatasetGroupResponse -> UpdateDatasetGroupResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDatasetGroupResponse]
ReadPrec UpdateDatasetGroupResponse
Int -> ReadS UpdateDatasetGroupResponse
ReadS [UpdateDatasetGroupResponse]
(Int -> ReadS UpdateDatasetGroupResponse)
-> ReadS [UpdateDatasetGroupResponse]
-> ReadPrec UpdateDatasetGroupResponse
-> ReadPrec [UpdateDatasetGroupResponse]
-> Read UpdateDatasetGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDatasetGroupResponse]
$creadListPrec :: ReadPrec [UpdateDatasetGroupResponse]
readPrec :: ReadPrec UpdateDatasetGroupResponse
$creadPrec :: ReadPrec UpdateDatasetGroupResponse
readList :: ReadS [UpdateDatasetGroupResponse]
$creadList :: ReadS [UpdateDatasetGroupResponse]
readsPrec :: Int -> ReadS UpdateDatasetGroupResponse
$creadsPrec :: Int -> ReadS UpdateDatasetGroupResponse
Prelude.Read, Int -> UpdateDatasetGroupResponse -> ShowS
[UpdateDatasetGroupResponse] -> ShowS
UpdateDatasetGroupResponse -> String
(Int -> UpdateDatasetGroupResponse -> ShowS)
-> (UpdateDatasetGroupResponse -> String)
-> ([UpdateDatasetGroupResponse] -> ShowS)
-> Show UpdateDatasetGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDatasetGroupResponse] -> ShowS
$cshowList :: [UpdateDatasetGroupResponse] -> ShowS
show :: UpdateDatasetGroupResponse -> String
$cshow :: UpdateDatasetGroupResponse -> String
showsPrec :: Int -> UpdateDatasetGroupResponse -> ShowS
$cshowsPrec :: Int -> UpdateDatasetGroupResponse -> ShowS
Prelude.Show, (forall x.
 UpdateDatasetGroupResponse -> Rep UpdateDatasetGroupResponse x)
-> (forall x.
    Rep UpdateDatasetGroupResponse x -> UpdateDatasetGroupResponse)
-> Generic UpdateDatasetGroupResponse
forall x.
Rep UpdateDatasetGroupResponse x -> UpdateDatasetGroupResponse
forall x.
UpdateDatasetGroupResponse -> Rep UpdateDatasetGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDatasetGroupResponse x -> UpdateDatasetGroupResponse
$cfrom :: forall x.
UpdateDatasetGroupResponse -> Rep UpdateDatasetGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDatasetGroupResponse' 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:
--
-- 'httpStatus', 'updateDatasetGroupResponse_httpStatus' - The response's http status code.
newUpdateDatasetGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDatasetGroupResponse
newUpdateDatasetGroupResponse :: Int -> UpdateDatasetGroupResponse
newUpdateDatasetGroupResponse Int
pHttpStatus_ =
  UpdateDatasetGroupResponse' :: Int -> UpdateDatasetGroupResponse
UpdateDatasetGroupResponse'
    { $sel:httpStatus:UpdateDatasetGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData UpdateDatasetGroupResponse