{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.FSx.Types.Alias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.FSx.Types.Alias where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FSx.Types.AliasLifecycle
import qualified Amazonka.Prelude as Prelude

-- | A DNS alias that is associated with the file system. You can use a DNS
-- alias to access a file system using user-defined DNS names, in addition
-- to the default DNS name that Amazon FSx assigns to the file system. For
-- more information, see
-- <https://docs.aws.amazon.com/fsx/latest/WindowsGuide/managing-dns-aliases.html DNS aliases>
-- in the /FSx for Windows File Server User Guide/.
--
-- /See:/ 'newAlias' smart constructor.
data Alias = Alias'
  { -- | Describes the state of the DNS alias.
    --
    -- -   AVAILABLE - The DNS alias is associated with an Amazon FSx file
    --     system.
    --
    -- -   CREATING - Amazon FSx is creating the DNS alias and associating it
    --     with the file system.
    --
    -- -   CREATE_FAILED - Amazon FSx was unable to associate the DNS alias
    --     with the file system.
    --
    -- -   DELETING - Amazon FSx is disassociating the DNS alias from the file
    --     system and deleting it.
    --
    -- -   DELETE_FAILED - Amazon FSx was unable to disassociate the DNS alias
    --     from the file system.
    Alias -> Maybe AliasLifecycle
lifecycle :: Prelude.Maybe AliasLifecycle,
    -- | The name of the DNS alias. The alias name has to meet the following
    -- requirements:
    --
    -- -   Formatted as a fully-qualified domain name (FQDN),
    --     @hostname.domain@, for example, @accounting.example.com@.
    --
    -- -   Can contain alphanumeric characters, the underscore (_), and the
    --     hyphen (-).
    --
    -- -   Cannot start or end with a hyphen.
    --
    -- -   Can start with a numeric.
    --
    -- For DNS names, Amazon FSx stores alphabetic characters as lowercase
    -- letters (a-z), regardless of how you specify them: as uppercase letters,
    -- lowercase letters, or the corresponding letters in escape codes.
    Alias -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Alias -> Alias -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alias -> Alias -> Bool
$c/= :: Alias -> Alias -> Bool
== :: Alias -> Alias -> Bool
$c== :: Alias -> Alias -> Bool
Prelude.Eq, ReadPrec [Alias]
ReadPrec Alias
Int -> ReadS Alias
ReadS [Alias]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alias]
$creadListPrec :: ReadPrec [Alias]
readPrec :: ReadPrec Alias
$creadPrec :: ReadPrec Alias
readList :: ReadS [Alias]
$creadList :: ReadS [Alias]
readsPrec :: Int -> ReadS Alias
$creadsPrec :: Int -> ReadS Alias
Prelude.Read, Int -> Alias -> ShowS
[Alias] -> ShowS
Alias -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alias] -> ShowS
$cshowList :: [Alias] -> ShowS
show :: Alias -> String
$cshow :: Alias -> String
showsPrec :: Int -> Alias -> ShowS
$cshowsPrec :: Int -> Alias -> ShowS
Prelude.Show, forall x. Rep Alias x -> Alias
forall x. Alias -> Rep Alias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Alias x -> Alias
$cfrom :: forall x. Alias -> Rep Alias x
Prelude.Generic)

-- |
-- Create a value of 'Alias' 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:
--
-- 'lifecycle', 'alias_lifecycle' - Describes the state of the DNS alias.
--
-- -   AVAILABLE - The DNS alias is associated with an Amazon FSx file
--     system.
--
-- -   CREATING - Amazon FSx is creating the DNS alias and associating it
--     with the file system.
--
-- -   CREATE_FAILED - Amazon FSx was unable to associate the DNS alias
--     with the file system.
--
-- -   DELETING - Amazon FSx is disassociating the DNS alias from the file
--     system and deleting it.
--
-- -   DELETE_FAILED - Amazon FSx was unable to disassociate the DNS alias
--     from the file system.
--
-- 'name', 'alias_name' - The name of the DNS alias. The alias name has to meet the following
-- requirements:
--
-- -   Formatted as a fully-qualified domain name (FQDN),
--     @hostname.domain@, for example, @accounting.example.com@.
--
-- -   Can contain alphanumeric characters, the underscore (_), and the
--     hyphen (-).
--
-- -   Cannot start or end with a hyphen.
--
-- -   Can start with a numeric.
--
-- For DNS names, Amazon FSx stores alphabetic characters as lowercase
-- letters (a-z), regardless of how you specify them: as uppercase letters,
-- lowercase letters, or the corresponding letters in escape codes.
newAlias ::
  Alias
newAlias :: Alias
newAlias =
  Alias'
    { $sel:lifecycle:Alias' :: Maybe AliasLifecycle
lifecycle = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Alias' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the state of the DNS alias.
--
-- -   AVAILABLE - The DNS alias is associated with an Amazon FSx file
--     system.
--
-- -   CREATING - Amazon FSx is creating the DNS alias and associating it
--     with the file system.
--
-- -   CREATE_FAILED - Amazon FSx was unable to associate the DNS alias
--     with the file system.
--
-- -   DELETING - Amazon FSx is disassociating the DNS alias from the file
--     system and deleting it.
--
-- -   DELETE_FAILED - Amazon FSx was unable to disassociate the DNS alias
--     from the file system.
alias_lifecycle :: Lens.Lens' Alias (Prelude.Maybe AliasLifecycle)
alias_lifecycle :: Lens' Alias (Maybe AliasLifecycle)
alias_lifecycle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alias' {Maybe AliasLifecycle
lifecycle :: Maybe AliasLifecycle
$sel:lifecycle:Alias' :: Alias -> Maybe AliasLifecycle
lifecycle} -> Maybe AliasLifecycle
lifecycle) (\s :: Alias
s@Alias' {} Maybe AliasLifecycle
a -> Alias
s {$sel:lifecycle:Alias' :: Maybe AliasLifecycle
lifecycle = Maybe AliasLifecycle
a} :: Alias)

-- | The name of the DNS alias. The alias name has to meet the following
-- requirements:
--
-- -   Formatted as a fully-qualified domain name (FQDN),
--     @hostname.domain@, for example, @accounting.example.com@.
--
-- -   Can contain alphanumeric characters, the underscore (_), and the
--     hyphen (-).
--
-- -   Cannot start or end with a hyphen.
--
-- -   Can start with a numeric.
--
-- For DNS names, Amazon FSx stores alphabetic characters as lowercase
-- letters (a-z), regardless of how you specify them: as uppercase letters,
-- lowercase letters, or the corresponding letters in escape codes.
alias_name :: Lens.Lens' Alias (Prelude.Maybe Prelude.Text)
alias_name :: Lens' Alias (Maybe Text)
alias_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alias' {Maybe Text
name :: Maybe Text
$sel:name:Alias' :: Alias -> Maybe Text
name} -> Maybe Text
name) (\s :: Alias
s@Alias' {} Maybe Text
a -> Alias
s {$sel:name:Alias' :: Maybe Text
name = Maybe Text
a} :: Alias)

instance Data.FromJSON Alias where
  parseJSON :: Value -> Parser Alias
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Alias"
      ( \Object
x ->
          Maybe AliasLifecycle -> Maybe Text -> Alias
Alias'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Lifecycle")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
      )

instance Prelude.Hashable Alias where
  hashWithSalt :: Int -> Alias -> Int
hashWithSalt Int
_salt Alias' {Maybe Text
Maybe AliasLifecycle
name :: Maybe Text
lifecycle :: Maybe AliasLifecycle
$sel:name:Alias' :: Alias -> Maybe Text
$sel:lifecycle:Alias' :: Alias -> Maybe AliasLifecycle
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AliasLifecycle
lifecycle
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData Alias where
  rnf :: Alias -> ()
rnf Alias' {Maybe Text
Maybe AliasLifecycle
name :: Maybe Text
lifecycle :: Maybe AliasLifecycle
$sel:name:Alias' :: Alias -> Maybe Text
$sel:lifecycle:Alias' :: Alias -> Maybe AliasLifecycle
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AliasLifecycle
lifecycle
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name