{-# 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.DeviceFarm.Types.Radios
-- 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)
module Amazonka.DeviceFarm.Types.Radios where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the set of radios and their states on a device. Examples of
-- radios include Wi-Fi, GPS, Bluetooth, and NFC.
--
-- /See:/ 'newRadios' smart constructor.
data Radios = Radios'
  { -- | True if NFC is enabled at the beginning of the test. Otherwise, false.
    Radios -> Maybe Bool
nfc :: Prelude.Maybe Prelude.Bool,
    -- | True if GPS is enabled at the beginning of the test. Otherwise, false.
    Radios -> Maybe Bool
gps :: Prelude.Maybe Prelude.Bool,
    -- | True if Bluetooth is enabled at the beginning of the test. Otherwise,
    -- false.
    Radios -> Maybe Bool
bluetooth :: Prelude.Maybe Prelude.Bool,
    -- | True if Wi-Fi is enabled at the beginning of the test. Otherwise, false.
    Radios -> Maybe Bool
wifi :: Prelude.Maybe Prelude.Bool
  }
  deriving (Radios -> Radios -> Bool
(Radios -> Radios -> Bool)
-> (Radios -> Radios -> Bool) -> Eq Radios
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Radios -> Radios -> Bool
$c/= :: Radios -> Radios -> Bool
== :: Radios -> Radios -> Bool
$c== :: Radios -> Radios -> Bool
Prelude.Eq, ReadPrec [Radios]
ReadPrec Radios
Int -> ReadS Radios
ReadS [Radios]
(Int -> ReadS Radios)
-> ReadS [Radios]
-> ReadPrec Radios
-> ReadPrec [Radios]
-> Read Radios
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Radios]
$creadListPrec :: ReadPrec [Radios]
readPrec :: ReadPrec Radios
$creadPrec :: ReadPrec Radios
readList :: ReadS [Radios]
$creadList :: ReadS [Radios]
readsPrec :: Int -> ReadS Radios
$creadsPrec :: Int -> ReadS Radios
Prelude.Read, Int -> Radios -> ShowS
[Radios] -> ShowS
Radios -> String
(Int -> Radios -> ShowS)
-> (Radios -> String) -> ([Radios] -> ShowS) -> Show Radios
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Radios] -> ShowS
$cshowList :: [Radios] -> ShowS
show :: Radios -> String
$cshow :: Radios -> String
showsPrec :: Int -> Radios -> ShowS
$cshowsPrec :: Int -> Radios -> ShowS
Prelude.Show, (forall x. Radios -> Rep Radios x)
-> (forall x. Rep Radios x -> Radios) -> Generic Radios
forall x. Rep Radios x -> Radios
forall x. Radios -> Rep Radios x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Radios x -> Radios
$cfrom :: forall x. Radios -> Rep Radios x
Prelude.Generic)

-- |
-- Create a value of 'Radios' 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:
--
-- 'nfc', 'radios_nfc' - True if NFC is enabled at the beginning of the test. Otherwise, false.
--
-- 'gps', 'radios_gps' - True if GPS is enabled at the beginning of the test. Otherwise, false.
--
-- 'bluetooth', 'radios_bluetooth' - True if Bluetooth is enabled at the beginning of the test. Otherwise,
-- false.
--
-- 'wifi', 'radios_wifi' - True if Wi-Fi is enabled at the beginning of the test. Otherwise, false.
newRadios ::
  Radios
newRadios :: Radios
newRadios =
  Radios' :: Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Radios
Radios'
    { $sel:nfc:Radios' :: Maybe Bool
nfc = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:gps:Radios' :: Maybe Bool
gps = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:bluetooth:Radios' :: Maybe Bool
bluetooth = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:wifi:Radios' :: Maybe Bool
wifi = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | True if NFC is enabled at the beginning of the test. Otherwise, false.
radios_nfc :: Lens.Lens' Radios (Prelude.Maybe Prelude.Bool)
radios_nfc :: (Maybe Bool -> f (Maybe Bool)) -> Radios -> f Radios
radios_nfc = (Radios -> Maybe Bool)
-> (Radios -> Maybe Bool -> Radios)
-> Lens Radios Radios (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Radios' {Maybe Bool
nfc :: Maybe Bool
$sel:nfc:Radios' :: Radios -> Maybe Bool
nfc} -> Maybe Bool
nfc) (\s :: Radios
s@Radios' {} Maybe Bool
a -> Radios
s {$sel:nfc:Radios' :: Maybe Bool
nfc = Maybe Bool
a} :: Radios)

-- | True if GPS is enabled at the beginning of the test. Otherwise, false.
radios_gps :: Lens.Lens' Radios (Prelude.Maybe Prelude.Bool)
radios_gps :: (Maybe Bool -> f (Maybe Bool)) -> Radios -> f Radios
radios_gps = (Radios -> Maybe Bool)
-> (Radios -> Maybe Bool -> Radios)
-> Lens Radios Radios (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Radios' {Maybe Bool
gps :: Maybe Bool
$sel:gps:Radios' :: Radios -> Maybe Bool
gps} -> Maybe Bool
gps) (\s :: Radios
s@Radios' {} Maybe Bool
a -> Radios
s {$sel:gps:Radios' :: Maybe Bool
gps = Maybe Bool
a} :: Radios)

-- | True if Bluetooth is enabled at the beginning of the test. Otherwise,
-- false.
radios_bluetooth :: Lens.Lens' Radios (Prelude.Maybe Prelude.Bool)
radios_bluetooth :: (Maybe Bool -> f (Maybe Bool)) -> Radios -> f Radios
radios_bluetooth = (Radios -> Maybe Bool)
-> (Radios -> Maybe Bool -> Radios)
-> Lens Radios Radios (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Radios' {Maybe Bool
bluetooth :: Maybe Bool
$sel:bluetooth:Radios' :: Radios -> Maybe Bool
bluetooth} -> Maybe Bool
bluetooth) (\s :: Radios
s@Radios' {} Maybe Bool
a -> Radios
s {$sel:bluetooth:Radios' :: Maybe Bool
bluetooth = Maybe Bool
a} :: Radios)

-- | True if Wi-Fi is enabled at the beginning of the test. Otherwise, false.
radios_wifi :: Lens.Lens' Radios (Prelude.Maybe Prelude.Bool)
radios_wifi :: (Maybe Bool -> f (Maybe Bool)) -> Radios -> f Radios
radios_wifi = (Radios -> Maybe Bool)
-> (Radios -> Maybe Bool -> Radios)
-> Lens Radios Radios (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Radios' {Maybe Bool
wifi :: Maybe Bool
$sel:wifi:Radios' :: Radios -> Maybe Bool
wifi} -> Maybe Bool
wifi) (\s :: Radios
s@Radios' {} Maybe Bool
a -> Radios
s {$sel:wifi:Radios' :: Maybe Bool
wifi = Maybe Bool
a} :: Radios)

instance Core.FromJSON Radios where
  parseJSON :: Value -> Parser Radios
parseJSON =
    String -> (Object -> Parser Radios) -> Value -> Parser Radios
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Radios"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Radios
Radios'
            (Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Radios)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Maybe Bool -> Maybe Bool -> Radios)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"nfc")
            Parser (Maybe Bool -> Maybe Bool -> Maybe Bool -> Radios)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> Maybe Bool -> Radios)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"gps")
            Parser (Maybe Bool -> Maybe Bool -> Radios)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> Radios)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bluetooth")
            Parser (Maybe Bool -> Radios)
-> Parser (Maybe Bool) -> Parser Radios
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"wifi")
      )

instance Prelude.Hashable Radios

instance Prelude.NFData Radios

instance Core.ToJSON Radios where
  toJSON :: Radios -> Value
toJSON Radios' {Maybe Bool
wifi :: Maybe Bool
bluetooth :: Maybe Bool
gps :: Maybe Bool
nfc :: Maybe Bool
$sel:wifi:Radios' :: Radios -> Maybe Bool
$sel:bluetooth:Radios' :: Radios -> Maybe Bool
$sel:gps:Radios' :: Radios -> Maybe Bool
$sel:nfc:Radios' :: Radios -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"nfc" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
nfc,
            (Text
"gps" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
gps,
            (Text
"bluetooth" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
bluetooth,
            (Text
"wifi" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
wifi
          ]
      )