{-# 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.SageMaker.Types.SourceIpConfig
-- 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.SageMaker.Types.SourceIpConfig where

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

-- | A list of IP address ranges
-- (<https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html CIDRs>).
-- Used to create an allow list of IP addresses for a private workforce.
-- Workers will only be able to login to their worker portal from an IP
-- address within this range. By default, a workforce isn\'t restricted to
-- specific IP addresses.
--
-- /See:/ 'newSourceIpConfig' smart constructor.
data SourceIpConfig = SourceIpConfig'
  { -- | A list of one to ten
    -- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html Classless Inter-Domain Routing>
    -- (CIDR) values.
    --
    -- Maximum: Ten CIDR values
    --
    -- The following Length Constraints apply to individual CIDR values in the
    -- CIDR value list.
    SourceIpConfig -> [Text]
cidrs :: [Prelude.Text]
  }
  deriving (SourceIpConfig -> SourceIpConfig -> Bool
(SourceIpConfig -> SourceIpConfig -> Bool)
-> (SourceIpConfig -> SourceIpConfig -> Bool) -> Eq SourceIpConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceIpConfig -> SourceIpConfig -> Bool
$c/= :: SourceIpConfig -> SourceIpConfig -> Bool
== :: SourceIpConfig -> SourceIpConfig -> Bool
$c== :: SourceIpConfig -> SourceIpConfig -> Bool
Prelude.Eq, ReadPrec [SourceIpConfig]
ReadPrec SourceIpConfig
Int -> ReadS SourceIpConfig
ReadS [SourceIpConfig]
(Int -> ReadS SourceIpConfig)
-> ReadS [SourceIpConfig]
-> ReadPrec SourceIpConfig
-> ReadPrec [SourceIpConfig]
-> Read SourceIpConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceIpConfig]
$creadListPrec :: ReadPrec [SourceIpConfig]
readPrec :: ReadPrec SourceIpConfig
$creadPrec :: ReadPrec SourceIpConfig
readList :: ReadS [SourceIpConfig]
$creadList :: ReadS [SourceIpConfig]
readsPrec :: Int -> ReadS SourceIpConfig
$creadsPrec :: Int -> ReadS SourceIpConfig
Prelude.Read, Int -> SourceIpConfig -> ShowS
[SourceIpConfig] -> ShowS
SourceIpConfig -> String
(Int -> SourceIpConfig -> ShowS)
-> (SourceIpConfig -> String)
-> ([SourceIpConfig] -> ShowS)
-> Show SourceIpConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceIpConfig] -> ShowS
$cshowList :: [SourceIpConfig] -> ShowS
show :: SourceIpConfig -> String
$cshow :: SourceIpConfig -> String
showsPrec :: Int -> SourceIpConfig -> ShowS
$cshowsPrec :: Int -> SourceIpConfig -> ShowS
Prelude.Show, (forall x. SourceIpConfig -> Rep SourceIpConfig x)
-> (forall x. Rep SourceIpConfig x -> SourceIpConfig)
-> Generic SourceIpConfig
forall x. Rep SourceIpConfig x -> SourceIpConfig
forall x. SourceIpConfig -> Rep SourceIpConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceIpConfig x -> SourceIpConfig
$cfrom :: forall x. SourceIpConfig -> Rep SourceIpConfig x
Prelude.Generic)

-- |
-- Create a value of 'SourceIpConfig' 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:
--
-- 'cidrs', 'sourceIpConfig_cidrs' - A list of one to ten
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html Classless Inter-Domain Routing>
-- (CIDR) values.
--
-- Maximum: Ten CIDR values
--
-- The following Length Constraints apply to individual CIDR values in the
-- CIDR value list.
newSourceIpConfig ::
  SourceIpConfig
newSourceIpConfig :: SourceIpConfig
newSourceIpConfig =
  SourceIpConfig' :: [Text] -> SourceIpConfig
SourceIpConfig' {$sel:cidrs:SourceIpConfig' :: [Text]
cidrs = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A list of one to ten
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html Classless Inter-Domain Routing>
-- (CIDR) values.
--
-- Maximum: Ten CIDR values
--
-- The following Length Constraints apply to individual CIDR values in the
-- CIDR value list.
sourceIpConfig_cidrs :: Lens.Lens' SourceIpConfig [Prelude.Text]
sourceIpConfig_cidrs :: ([Text] -> f [Text]) -> SourceIpConfig -> f SourceIpConfig
sourceIpConfig_cidrs = (SourceIpConfig -> [Text])
-> (SourceIpConfig -> [Text] -> SourceIpConfig)
-> Lens SourceIpConfig SourceIpConfig [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceIpConfig' {[Text]
cidrs :: [Text]
$sel:cidrs:SourceIpConfig' :: SourceIpConfig -> [Text]
cidrs} -> [Text]
cidrs) (\s :: SourceIpConfig
s@SourceIpConfig' {} [Text]
a -> SourceIpConfig
s {$sel:cidrs:SourceIpConfig' :: [Text]
cidrs = [Text]
a} :: SourceIpConfig) (([Text] -> f [Text]) -> SourceIpConfig -> f SourceIpConfig)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> SourceIpConfig
-> f SourceIpConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SourceIpConfig where
  parseJSON :: Value -> Parser SourceIpConfig
parseJSON =
    String
-> (Object -> Parser SourceIpConfig)
-> Value
-> Parser SourceIpConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourceIpConfig"
      ( \Object
x ->
          [Text] -> SourceIpConfig
SourceIpConfig'
            ([Text] -> SourceIpConfig)
-> Parser [Text] -> Parser SourceIpConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Cidrs" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SourceIpConfig

instance Prelude.NFData SourceIpConfig

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