{-# 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-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)
--
-- 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 need to
-- 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 Amazonka.EFS.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:/ '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 need to use short IDs for file system and mount
    -- target resources.
    PutAccountPreferences -> ResourceIdType
resourceIdType :: ResourceIdType
  }
  deriving (PutAccountPreferences -> PutAccountPreferences -> Bool
(PutAccountPreferences -> PutAccountPreferences -> Bool)
-> (PutAccountPreferences -> PutAccountPreferences -> Bool)
-> Eq PutAccountPreferences
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]
(Int -> ReadS PutAccountPreferences)
-> ReadS [PutAccountPreferences]
-> ReadPrec PutAccountPreferences
-> ReadPrec [PutAccountPreferences]
-> Read 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
(Int -> PutAccountPreferences -> ShowS)
-> (PutAccountPreferences -> String)
-> ([PutAccountPreferences] -> ShowS)
-> Show PutAccountPreferences
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. PutAccountPreferences -> Rep PutAccountPreferences x)
-> (forall x. Rep PutAccountPreferences x -> PutAccountPreferences)
-> Generic PutAccountPreferences
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 need to use short IDs for file system and mount
-- target resources.
newPutAccountPreferences ::
  -- | 'resourceIdType'
  ResourceIdType ->
  PutAccountPreferences
newPutAccountPreferences :: ResourceIdType -> PutAccountPreferences
newPutAccountPreferences ResourceIdType
pResourceIdType_ =
  PutAccountPreferences' :: ResourceIdType -> PutAccountPreferences
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 need to use short IDs for file system and mount
-- target resources.
putAccountPreferences_resourceIdType :: Lens.Lens' PutAccountPreferences ResourceIdType
putAccountPreferences_resourceIdType :: (ResourceIdType -> f ResourceIdType)
-> PutAccountPreferences -> f PutAccountPreferences
putAccountPreferences_resourceIdType = (PutAccountPreferences -> ResourceIdType)
-> (PutAccountPreferences
    -> ResourceIdType -> PutAccountPreferences)
-> Lens
     PutAccountPreferences
     PutAccountPreferences
     ResourceIdType
     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 :: PutAccountPreferences -> Request PutAccountPreferences
request = Service -> PutAccountPreferences -> Request PutAccountPreferences
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutAccountPreferences
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccountPreferences)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutAccountPreferences))
-> Logger
-> Service
-> Proxy PutAccountPreferences
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccountPreferences)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ResourceIdPreference -> Int -> PutAccountPreferencesResponse
PutAccountPreferencesResponse'
            (Maybe ResourceIdPreference
 -> Int -> PutAccountPreferencesResponse)
-> Either String (Maybe ResourceIdPreference)
-> Either String (Int -> PutAccountPreferencesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe ResourceIdPreference)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"ResourceIdPreference")
            Either String (Int -> PutAccountPreferencesResponse)
-> Either String Int -> Either String PutAccountPreferencesResponse
forall (f :: * -> *) a b. Applicative f => 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 PutAccountPreferences

instance Prelude.NFData PutAccountPreferences

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

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

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

instance Core.ToQuery PutAccountPreferences where
  toQuery :: PutAccountPreferences -> QueryString
toQuery = QueryString -> PutAccountPreferences -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutAccountPreferencesResponse
 -> PutAccountPreferencesResponse -> Bool)
-> (PutAccountPreferencesResponse
    -> PutAccountPreferencesResponse -> Bool)
-> Eq PutAccountPreferencesResponse
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]
(Int -> ReadS PutAccountPreferencesResponse)
-> ReadS [PutAccountPreferencesResponse]
-> ReadPrec PutAccountPreferencesResponse
-> ReadPrec [PutAccountPreferencesResponse]
-> Read 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
(Int -> PutAccountPreferencesResponse -> ShowS)
-> (PutAccountPreferencesResponse -> String)
-> ([PutAccountPreferencesResponse] -> ShowS)
-> Show PutAccountPreferencesResponse
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.
 PutAccountPreferencesResponse
 -> Rep PutAccountPreferencesResponse x)
-> (forall x.
    Rep PutAccountPreferencesResponse x
    -> PutAccountPreferencesResponse)
-> Generic PutAccountPreferencesResponse
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' :: Maybe ResourceIdPreference -> Int -> PutAccountPreferencesResponse
PutAccountPreferencesResponse'
    { $sel:resourceIdPreference:PutAccountPreferencesResponse' :: Maybe ResourceIdPreference
resourceIdPreference =
        Maybe 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 :: (Maybe ResourceIdPreference -> f (Maybe ResourceIdPreference))
-> PutAccountPreferencesResponse -> f PutAccountPreferencesResponse
putAccountPreferencesResponse_resourceIdPreference = (PutAccountPreferencesResponse -> Maybe ResourceIdPreference)
-> (PutAccountPreferencesResponse
    -> Maybe ResourceIdPreference -> PutAccountPreferencesResponse)
-> Lens
     PutAccountPreferencesResponse
     PutAccountPreferencesResponse
     (Maybe ResourceIdPreference)
     (Maybe 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 :: (Int -> f Int)
-> PutAccountPreferencesResponse -> f PutAccountPreferencesResponse
putAccountPreferencesResponse_httpStatus = (PutAccountPreferencesResponse -> Int)
-> (PutAccountPreferencesResponse
    -> Int -> PutAccountPreferencesResponse)
-> Lens
     PutAccountPreferencesResponse PutAccountPreferencesResponse Int Int
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