{-# 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.Nimble.AcceptEulas
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Accept EULAs.
module Amazonka.Nimble.AcceptEulas
  ( -- * Creating a Request
    AcceptEulas (..),
    newAcceptEulas,

    -- * Request Lenses
    acceptEulas_clientToken,
    acceptEulas_eulaIds,
    acceptEulas_studioId,

    -- * Destructuring the Response
    AcceptEulasResponse (..),
    newAcceptEulasResponse,

    -- * Response Lenses
    acceptEulasResponse_eulaAcceptances,
    acceptEulasResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Nimble.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAcceptEulas' smart constructor.
data AcceptEulas = AcceptEulas'
  { -- | Unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If you don’t specify a client token, the
    -- Amazon Web Services SDK automatically generates a client token and uses
    -- it for the request to ensure idempotency.
    AcceptEulas -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The EULA ID.
    AcceptEulas -> Maybe [Text]
eulaIds :: Prelude.Maybe [Prelude.Text],
    -- | The studio ID.
    AcceptEulas -> Text
studioId :: Prelude.Text
  }
  deriving (AcceptEulas -> AcceptEulas -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptEulas -> AcceptEulas -> Bool
$c/= :: AcceptEulas -> AcceptEulas -> Bool
== :: AcceptEulas -> AcceptEulas -> Bool
$c== :: AcceptEulas -> AcceptEulas -> Bool
Prelude.Eq, ReadPrec [AcceptEulas]
ReadPrec AcceptEulas
Int -> ReadS AcceptEulas
ReadS [AcceptEulas]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptEulas]
$creadListPrec :: ReadPrec [AcceptEulas]
readPrec :: ReadPrec AcceptEulas
$creadPrec :: ReadPrec AcceptEulas
readList :: ReadS [AcceptEulas]
$creadList :: ReadS [AcceptEulas]
readsPrec :: Int -> ReadS AcceptEulas
$creadsPrec :: Int -> ReadS AcceptEulas
Prelude.Read, Int -> AcceptEulas -> ShowS
[AcceptEulas] -> ShowS
AcceptEulas -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptEulas] -> ShowS
$cshowList :: [AcceptEulas] -> ShowS
show :: AcceptEulas -> String
$cshow :: AcceptEulas -> String
showsPrec :: Int -> AcceptEulas -> ShowS
$cshowsPrec :: Int -> AcceptEulas -> ShowS
Prelude.Show, forall x. Rep AcceptEulas x -> AcceptEulas
forall x. AcceptEulas -> Rep AcceptEulas x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptEulas x -> AcceptEulas
$cfrom :: forall x. AcceptEulas -> Rep AcceptEulas x
Prelude.Generic)

-- |
-- Create a value of 'AcceptEulas' 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:
--
-- 'clientToken', 'acceptEulas_clientToken' - Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
--
-- 'eulaIds', 'acceptEulas_eulaIds' - The EULA ID.
--
-- 'studioId', 'acceptEulas_studioId' - The studio ID.
newAcceptEulas ::
  -- | 'studioId'
  Prelude.Text ->
  AcceptEulas
newAcceptEulas :: Text -> AcceptEulas
newAcceptEulas Text
pStudioId_ =
  AcceptEulas'
    { $sel:clientToken:AcceptEulas' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:eulaIds:AcceptEulas' :: Maybe [Text]
eulaIds = forall a. Maybe a
Prelude.Nothing,
      $sel:studioId:AcceptEulas' :: Text
studioId = Text
pStudioId_
    }

-- | Unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If you don’t specify a client token, the
-- Amazon Web Services SDK automatically generates a client token and uses
-- it for the request to ensure idempotency.
acceptEulas_clientToken :: Lens.Lens' AcceptEulas (Prelude.Maybe Prelude.Text)
acceptEulas_clientToken :: Lens' AcceptEulas (Maybe Text)
acceptEulas_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptEulas' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: AcceptEulas
s@AcceptEulas' {} Maybe Text
a -> AcceptEulas
s {$sel:clientToken:AcceptEulas' :: Maybe Text
clientToken = Maybe Text
a} :: AcceptEulas)

-- | The EULA ID.
acceptEulas_eulaIds :: Lens.Lens' AcceptEulas (Prelude.Maybe [Prelude.Text])
acceptEulas_eulaIds :: Lens' AcceptEulas (Maybe [Text])
acceptEulas_eulaIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptEulas' {Maybe [Text]
eulaIds :: Maybe [Text]
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
eulaIds} -> Maybe [Text]
eulaIds) (\s :: AcceptEulas
s@AcceptEulas' {} Maybe [Text]
a -> AcceptEulas
s {$sel:eulaIds:AcceptEulas' :: Maybe [Text]
eulaIds = Maybe [Text]
a} :: AcceptEulas) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The studio ID.
acceptEulas_studioId :: Lens.Lens' AcceptEulas Prelude.Text
acceptEulas_studioId :: Lens' AcceptEulas Text
acceptEulas_studioId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptEulas' {Text
studioId :: Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
studioId} -> Text
studioId) (\s :: AcceptEulas
s@AcceptEulas' {} Text
a -> AcceptEulas
s {$sel:studioId:AcceptEulas' :: Text
studioId = Text
a} :: AcceptEulas)

instance Core.AWSRequest AcceptEulas where
  type AWSResponse AcceptEulas = AcceptEulasResponse
  request :: (Service -> Service) -> AcceptEulas -> Request AcceptEulas
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 AcceptEulas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptEulas)))
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 [EulaAcceptance] -> Int -> AcceptEulasResponse
AcceptEulasResponse'
            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
"eulaAcceptances"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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 AcceptEulas where
  hashWithSalt :: Int -> AcceptEulas -> Int
hashWithSalt Int
_salt AcceptEulas' {Maybe [Text]
Maybe Text
Text
studioId :: Text
eulaIds :: Maybe [Text]
clientToken :: Maybe Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
eulaIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
studioId

instance Prelude.NFData AcceptEulas where
  rnf :: AcceptEulas -> ()
rnf AcceptEulas' {Maybe [Text]
Maybe Text
Text
studioId :: Text
eulaIds :: Maybe [Text]
clientToken :: Maybe Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
eulaIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
studioId

instance Data.ToHeaders AcceptEulas where
  toHeaders :: AcceptEulas -> ResponseHeaders
toHeaders AcceptEulas' {Maybe [Text]
Maybe Text
Text
studioId :: Text
eulaIds :: Maybe [Text]
clientToken :: Maybe Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amz-Client-Token" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Maybe Text
clientToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.ToJSON AcceptEulas where
  toJSON :: AcceptEulas -> Value
toJSON AcceptEulas' {Maybe [Text]
Maybe Text
Text
studioId :: Text
eulaIds :: Maybe [Text]
clientToken :: Maybe Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"eulaIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
eulaIds]
      )

instance Data.ToPath AcceptEulas where
  toPath :: AcceptEulas -> ByteString
toPath AcceptEulas' {Maybe [Text]
Maybe Text
Text
studioId :: Text
eulaIds :: Maybe [Text]
clientToken :: Maybe Text
$sel:studioId:AcceptEulas' :: AcceptEulas -> Text
$sel:eulaIds:AcceptEulas' :: AcceptEulas -> Maybe [Text]
$sel:clientToken:AcceptEulas' :: AcceptEulas -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-08-01/studios/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
studioId,
        ByteString
"/eula-acceptances"
      ]

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

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

-- |
-- Create a value of 'AcceptEulasResponse' 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:
--
-- 'eulaAcceptances', 'acceptEulasResponse_eulaAcceptances' - A collection of EULA acceptances.
--
-- 'httpStatus', 'acceptEulasResponse_httpStatus' - The response's http status code.
newAcceptEulasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AcceptEulasResponse
newAcceptEulasResponse :: Int -> AcceptEulasResponse
newAcceptEulasResponse Int
pHttpStatus_ =
  AcceptEulasResponse'
    { $sel:eulaAcceptances:AcceptEulasResponse' :: Maybe [EulaAcceptance]
eulaAcceptances =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AcceptEulasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of EULA acceptances.
acceptEulasResponse_eulaAcceptances :: Lens.Lens' AcceptEulasResponse (Prelude.Maybe [EulaAcceptance])
acceptEulasResponse_eulaAcceptances :: Lens' AcceptEulasResponse (Maybe [EulaAcceptance])
acceptEulasResponse_eulaAcceptances = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptEulasResponse' {Maybe [EulaAcceptance]
eulaAcceptances :: Maybe [EulaAcceptance]
$sel:eulaAcceptances:AcceptEulasResponse' :: AcceptEulasResponse -> Maybe [EulaAcceptance]
eulaAcceptances} -> Maybe [EulaAcceptance]
eulaAcceptances) (\s :: AcceptEulasResponse
s@AcceptEulasResponse' {} Maybe [EulaAcceptance]
a -> AcceptEulasResponse
s {$sel:eulaAcceptances:AcceptEulasResponse' :: Maybe [EulaAcceptance]
eulaAcceptances = Maybe [EulaAcceptance]
a} :: AcceptEulasResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData AcceptEulasResponse where
  rnf :: AcceptEulasResponse -> ()
rnf AcceptEulasResponse' {Int
Maybe [EulaAcceptance]
httpStatus :: Int
eulaAcceptances :: Maybe [EulaAcceptance]
$sel:httpStatus:AcceptEulasResponse' :: AcceptEulasResponse -> Int
$sel:eulaAcceptances:AcceptEulasResponse' :: AcceptEulasResponse -> Maybe [EulaAcceptance]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EulaAcceptance]
eulaAcceptances
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus