{-# 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.EFS.PutAccountPreferences
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Use this operation to set the account preference in the current Amazon
-- Web Services Region to use long 17 character (63 bit) or short 8
-- character (32 bit) resource IDs for new EFS file system and mount target
-- resources. All existing resource IDs are not affected by any changes you
-- make. You can set the ID preference during the opt-in period as EFS
-- transitions to long resource IDs. For more information, see
-- <https://docs.aws.amazon.com/efs/latest/ug/manage-efs-resource-ids.html Managing Amazon EFS resource IDs>.
--
-- Starting in October, 2021, you will receive an error if you try to set
-- the account preference to use the short 8 character format resource ID.
-- Contact Amazon Web Services support if you receive an error and must use
-- short IDs for file system and mount target resources.
module Amazonka.EFS.PutAccountPreferences
  ( -- * Creating a Request
    PutAccountPreferences (..),
    newPutAccountPreferences,

    -- * Request Lenses
    putAccountPreferences_resourceIdType,

    -- * Destructuring the Response
    PutAccountPreferencesResponse (..),
    newPutAccountPreferencesResponse,

    -- * Response Lenses
    putAccountPreferencesResponse_resourceIdPreference,
    putAccountPreferencesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newPutAccountPreferences' smart constructor.
data PutAccountPreferences = PutAccountPreferences'
  { -- | Specifies the EFS resource ID preference to set for the user\'s Amazon
    -- Web Services account, in the current Amazon Web Services Region, either
    -- @LONG_ID@ (17 characters), or @SHORT_ID@ (8 characters).
    --
    -- Starting in October, 2021, you will receive an error when setting the
    -- account preference to @SHORT_ID@. Contact Amazon Web Services support if
    -- you receive an error and must use short IDs for file system and mount
    -- target resources.
    PutAccountPreferences -> ResourceIdType
resourceIdType :: ResourceIdType
  }
  deriving (PutAccountPreferences -> PutAccountPreferences -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccountPreferences -> PutAccountPreferences -> Bool
$c/= :: PutAccountPreferences -> PutAccountPreferences -> Bool
== :: PutAccountPreferences -> PutAccountPreferences -> Bool
$c== :: PutAccountPreferences -> PutAccountPreferences -> Bool
Prelude.Eq, ReadPrec [PutAccountPreferences]
ReadPrec PutAccountPreferences
Int -> ReadS PutAccountPreferences
ReadS [PutAccountPreferences]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccountPreferences]
$creadListPrec :: ReadPrec [PutAccountPreferences]
readPrec :: ReadPrec PutAccountPreferences
$creadPrec :: ReadPrec PutAccountPreferences
readList :: ReadS [PutAccountPreferences]
$creadList :: ReadS [PutAccountPreferences]
readsPrec :: Int -> ReadS PutAccountPreferences
$creadsPrec :: Int -> ReadS PutAccountPreferences
Prelude.Read, Int -> PutAccountPreferences -> ShowS
[PutAccountPreferences] -> ShowS
PutAccountPreferences -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccountPreferences] -> ShowS
$cshowList :: [PutAccountPreferences] -> ShowS
show :: PutAccountPreferences -> String
$cshow :: PutAccountPreferences -> String
showsPrec :: Int -> PutAccountPreferences -> ShowS
$cshowsPrec :: Int -> PutAccountPreferences -> ShowS
Prelude.Show, forall x. Rep PutAccountPreferences x -> PutAccountPreferences
forall x. PutAccountPreferences -> Rep PutAccountPreferences x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutAccountPreferences x -> PutAccountPreferences
$cfrom :: forall x. PutAccountPreferences -> Rep PutAccountPreferences x
Prelude.Generic)

-- |
-- Create a value of 'PutAccountPreferences' 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:
--
-- 'resourceIdType', 'putAccountPreferences_resourceIdType' - Specifies the EFS resource ID preference to set for the user\'s Amazon
-- Web Services account, in the current Amazon Web Services Region, either
-- @LONG_ID@ (17 characters), or @SHORT_ID@ (8 characters).
--
-- Starting in October, 2021, you will receive an error when setting the
-- account preference to @SHORT_ID@. Contact Amazon Web Services support if
-- you receive an error and must use short IDs for file system and mount
-- target resources.
newPutAccountPreferences ::
  -- | 'resourceIdType'
  ResourceIdType ->
  PutAccountPreferences
newPutAccountPreferences :: ResourceIdType -> PutAccountPreferences
newPutAccountPreferences ResourceIdType
pResourceIdType_ =
  PutAccountPreferences'
    { $sel:resourceIdType:PutAccountPreferences' :: ResourceIdType
resourceIdType =
        ResourceIdType
pResourceIdType_
    }

-- | Specifies the EFS resource ID preference to set for the user\'s Amazon
-- Web Services account, in the current Amazon Web Services Region, either
-- @LONG_ID@ (17 characters), or @SHORT_ID@ (8 characters).
--
-- Starting in October, 2021, you will receive an error when setting the
-- account preference to @SHORT_ID@. Contact Amazon Web Services support if
-- you receive an error and must use short IDs for file system and mount
-- target resources.
putAccountPreferences_resourceIdType :: Lens.Lens' PutAccountPreferences ResourceIdType
putAccountPreferences_resourceIdType :: Lens' PutAccountPreferences ResourceIdType
putAccountPreferences_resourceIdType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountPreferences' {ResourceIdType
resourceIdType :: ResourceIdType
$sel:resourceIdType:PutAccountPreferences' :: PutAccountPreferences -> ResourceIdType
resourceIdType} -> ResourceIdType
resourceIdType) (\s :: PutAccountPreferences
s@PutAccountPreferences' {} ResourceIdType
a -> PutAccountPreferences
s {$sel:resourceIdType:PutAccountPreferences' :: ResourceIdType
resourceIdType = ResourceIdType
a} :: PutAccountPreferences)

instance Core.AWSRequest PutAccountPreferences where
  type
    AWSResponse PutAccountPreferences =
      PutAccountPreferencesResponse
  request :: (Service -> Service)
-> PutAccountPreferences -> Request PutAccountPreferences
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutAccountPreferences
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccountPreferences)))
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 ResourceIdPreference -> Int -> PutAccountPreferencesResponse
PutAccountPreferencesResponse'
            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
"ResourceIdPreference")
            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 PutAccountPreferences where
  hashWithSalt :: Int -> PutAccountPreferences -> Int
hashWithSalt Int
_salt PutAccountPreferences' {ResourceIdType
resourceIdType :: ResourceIdType
$sel:resourceIdType:PutAccountPreferences' :: PutAccountPreferences -> ResourceIdType
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceIdType
resourceIdType

instance Prelude.NFData PutAccountPreferences where
  rnf :: PutAccountPreferences -> ()
rnf PutAccountPreferences' {ResourceIdType
resourceIdType :: ResourceIdType
$sel:resourceIdType:PutAccountPreferences' :: PutAccountPreferences -> ResourceIdType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ResourceIdType
resourceIdType

instance Data.ToHeaders PutAccountPreferences where
  toHeaders :: PutAccountPreferences -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON PutAccountPreferences where
  toJSON :: PutAccountPreferences -> Value
toJSON PutAccountPreferences' {ResourceIdType
resourceIdType :: ResourceIdType
$sel:resourceIdType:PutAccountPreferences' :: PutAccountPreferences -> ResourceIdType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ResourceIdType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceIdType
resourceIdType)
          ]
      )

instance Data.ToPath PutAccountPreferences where
  toPath :: PutAccountPreferences -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/2015-02-01/account-preferences"

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

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

-- |
-- Create a value of 'PutAccountPreferencesResponse' 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:
--
-- 'resourceIdPreference', 'putAccountPreferencesResponse_resourceIdPreference' - Undocumented member.
--
-- 'httpStatus', 'putAccountPreferencesResponse_httpStatus' - The response's http status code.
newPutAccountPreferencesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutAccountPreferencesResponse
newPutAccountPreferencesResponse :: Int -> PutAccountPreferencesResponse
newPutAccountPreferencesResponse Int
pHttpStatus_ =
  PutAccountPreferencesResponse'
    { $sel:resourceIdPreference:PutAccountPreferencesResponse' :: Maybe ResourceIdPreference
resourceIdPreference =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutAccountPreferencesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
putAccountPreferencesResponse_resourceIdPreference :: Lens.Lens' PutAccountPreferencesResponse (Prelude.Maybe ResourceIdPreference)
putAccountPreferencesResponse_resourceIdPreference :: Lens' PutAccountPreferencesResponse (Maybe ResourceIdPreference)
putAccountPreferencesResponse_resourceIdPreference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountPreferencesResponse' {Maybe ResourceIdPreference
resourceIdPreference :: Maybe ResourceIdPreference
$sel:resourceIdPreference:PutAccountPreferencesResponse' :: PutAccountPreferencesResponse -> Maybe ResourceIdPreference
resourceIdPreference} -> Maybe ResourceIdPreference
resourceIdPreference) (\s :: PutAccountPreferencesResponse
s@PutAccountPreferencesResponse' {} Maybe ResourceIdPreference
a -> PutAccountPreferencesResponse
s {$sel:resourceIdPreference:PutAccountPreferencesResponse' :: Maybe ResourceIdPreference
resourceIdPreference = Maybe ResourceIdPreference
a} :: PutAccountPreferencesResponse)

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

instance Prelude.NFData PutAccountPreferencesResponse where
  rnf :: PutAccountPreferencesResponse -> ()
rnf PutAccountPreferencesResponse' {Int
Maybe ResourceIdPreference
httpStatus :: Int
resourceIdPreference :: Maybe ResourceIdPreference
$sel:httpStatus:PutAccountPreferencesResponse' :: PutAccountPreferencesResponse -> Int
$sel:resourceIdPreference:PutAccountPreferencesResponse' :: PutAccountPreferencesResponse -> Maybe ResourceIdPreference
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceIdPreference
resourceIdPreference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus