{-# 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.SecurityHub.Types.IpOrganizationDetails
-- 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.SecurityHub.Types.IpOrganizationDetails where

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

-- | Provides information about an internet provider.
--
-- /See:/ 'newIpOrganizationDetails' smart constructor.
data IpOrganizationDetails = IpOrganizationDetails'
  { -- | The name of the internet provider.
    IpOrganizationDetails -> Maybe Text
org :: Prelude.Maybe Prelude.Text,
    -- | The name of the organization that registered the ASN.
    IpOrganizationDetails -> Maybe Text
asnOrg :: Prelude.Maybe Prelude.Text,
    -- | The Autonomous System Number (ASN) of the internet provider
    IpOrganizationDetails -> Maybe Int
asn :: Prelude.Maybe Prelude.Int,
    -- | The ISP information for the internet provider.
    IpOrganizationDetails -> Maybe Text
isp :: Prelude.Maybe Prelude.Text
  }
  deriving (IpOrganizationDetails -> IpOrganizationDetails -> Bool
(IpOrganizationDetails -> IpOrganizationDetails -> Bool)
-> (IpOrganizationDetails -> IpOrganizationDetails -> Bool)
-> Eq IpOrganizationDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpOrganizationDetails -> IpOrganizationDetails -> Bool
$c/= :: IpOrganizationDetails -> IpOrganizationDetails -> Bool
== :: IpOrganizationDetails -> IpOrganizationDetails -> Bool
$c== :: IpOrganizationDetails -> IpOrganizationDetails -> Bool
Prelude.Eq, ReadPrec [IpOrganizationDetails]
ReadPrec IpOrganizationDetails
Int -> ReadS IpOrganizationDetails
ReadS [IpOrganizationDetails]
(Int -> ReadS IpOrganizationDetails)
-> ReadS [IpOrganizationDetails]
-> ReadPrec IpOrganizationDetails
-> ReadPrec [IpOrganizationDetails]
-> Read IpOrganizationDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpOrganizationDetails]
$creadListPrec :: ReadPrec [IpOrganizationDetails]
readPrec :: ReadPrec IpOrganizationDetails
$creadPrec :: ReadPrec IpOrganizationDetails
readList :: ReadS [IpOrganizationDetails]
$creadList :: ReadS [IpOrganizationDetails]
readsPrec :: Int -> ReadS IpOrganizationDetails
$creadsPrec :: Int -> ReadS IpOrganizationDetails
Prelude.Read, Int -> IpOrganizationDetails -> ShowS
[IpOrganizationDetails] -> ShowS
IpOrganizationDetails -> String
(Int -> IpOrganizationDetails -> ShowS)
-> (IpOrganizationDetails -> String)
-> ([IpOrganizationDetails] -> ShowS)
-> Show IpOrganizationDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpOrganizationDetails] -> ShowS
$cshowList :: [IpOrganizationDetails] -> ShowS
show :: IpOrganizationDetails -> String
$cshow :: IpOrganizationDetails -> String
showsPrec :: Int -> IpOrganizationDetails -> ShowS
$cshowsPrec :: Int -> IpOrganizationDetails -> ShowS
Prelude.Show, (forall x. IpOrganizationDetails -> Rep IpOrganizationDetails x)
-> (forall x. Rep IpOrganizationDetails x -> IpOrganizationDetails)
-> Generic IpOrganizationDetails
forall x. Rep IpOrganizationDetails x -> IpOrganizationDetails
forall x. IpOrganizationDetails -> Rep IpOrganizationDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpOrganizationDetails x -> IpOrganizationDetails
$cfrom :: forall x. IpOrganizationDetails -> Rep IpOrganizationDetails x
Prelude.Generic)

-- |
-- Create a value of 'IpOrganizationDetails' 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:
--
-- 'org', 'ipOrganizationDetails_org' - The name of the internet provider.
--
-- 'asnOrg', 'ipOrganizationDetails_asnOrg' - The name of the organization that registered the ASN.
--
-- 'asn', 'ipOrganizationDetails_asn' - The Autonomous System Number (ASN) of the internet provider
--
-- 'isp', 'ipOrganizationDetails_isp' - The ISP information for the internet provider.
newIpOrganizationDetails ::
  IpOrganizationDetails
newIpOrganizationDetails :: IpOrganizationDetails
newIpOrganizationDetails =
  IpOrganizationDetails' :: Maybe Text
-> Maybe Text -> Maybe Int -> Maybe Text -> IpOrganizationDetails
IpOrganizationDetails'
    { $sel:org:IpOrganizationDetails' :: Maybe Text
org = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:asnOrg:IpOrganizationDetails' :: Maybe Text
asnOrg = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:asn:IpOrganizationDetails' :: Maybe Int
asn = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:isp:IpOrganizationDetails' :: Maybe Text
isp = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the internet provider.
ipOrganizationDetails_org :: Lens.Lens' IpOrganizationDetails (Prelude.Maybe Prelude.Text)
ipOrganizationDetails_org :: (Maybe Text -> f (Maybe Text))
-> IpOrganizationDetails -> f IpOrganizationDetails
ipOrganizationDetails_org = (IpOrganizationDetails -> Maybe Text)
-> (IpOrganizationDetails -> Maybe Text -> IpOrganizationDetails)
-> Lens
     IpOrganizationDetails
     IpOrganizationDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpOrganizationDetails' {Maybe Text
org :: Maybe Text
$sel:org:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
org} -> Maybe Text
org) (\s :: IpOrganizationDetails
s@IpOrganizationDetails' {} Maybe Text
a -> IpOrganizationDetails
s {$sel:org:IpOrganizationDetails' :: Maybe Text
org = Maybe Text
a} :: IpOrganizationDetails)

-- | The name of the organization that registered the ASN.
ipOrganizationDetails_asnOrg :: Lens.Lens' IpOrganizationDetails (Prelude.Maybe Prelude.Text)
ipOrganizationDetails_asnOrg :: (Maybe Text -> f (Maybe Text))
-> IpOrganizationDetails -> f IpOrganizationDetails
ipOrganizationDetails_asnOrg = (IpOrganizationDetails -> Maybe Text)
-> (IpOrganizationDetails -> Maybe Text -> IpOrganizationDetails)
-> Lens
     IpOrganizationDetails
     IpOrganizationDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpOrganizationDetails' {Maybe Text
asnOrg :: Maybe Text
$sel:asnOrg:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
asnOrg} -> Maybe Text
asnOrg) (\s :: IpOrganizationDetails
s@IpOrganizationDetails' {} Maybe Text
a -> IpOrganizationDetails
s {$sel:asnOrg:IpOrganizationDetails' :: Maybe Text
asnOrg = Maybe Text
a} :: IpOrganizationDetails)

-- | The Autonomous System Number (ASN) of the internet provider
ipOrganizationDetails_asn :: Lens.Lens' IpOrganizationDetails (Prelude.Maybe Prelude.Int)
ipOrganizationDetails_asn :: (Maybe Int -> f (Maybe Int))
-> IpOrganizationDetails -> f IpOrganizationDetails
ipOrganizationDetails_asn = (IpOrganizationDetails -> Maybe Int)
-> (IpOrganizationDetails -> Maybe Int -> IpOrganizationDetails)
-> Lens
     IpOrganizationDetails IpOrganizationDetails (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpOrganizationDetails' {Maybe Int
asn :: Maybe Int
$sel:asn:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Int
asn} -> Maybe Int
asn) (\s :: IpOrganizationDetails
s@IpOrganizationDetails' {} Maybe Int
a -> IpOrganizationDetails
s {$sel:asn:IpOrganizationDetails' :: Maybe Int
asn = Maybe Int
a} :: IpOrganizationDetails)

-- | The ISP information for the internet provider.
ipOrganizationDetails_isp :: Lens.Lens' IpOrganizationDetails (Prelude.Maybe Prelude.Text)
ipOrganizationDetails_isp :: (Maybe Text -> f (Maybe Text))
-> IpOrganizationDetails -> f IpOrganizationDetails
ipOrganizationDetails_isp = (IpOrganizationDetails -> Maybe Text)
-> (IpOrganizationDetails -> Maybe Text -> IpOrganizationDetails)
-> Lens
     IpOrganizationDetails
     IpOrganizationDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpOrganizationDetails' {Maybe Text
isp :: Maybe Text
$sel:isp:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
isp} -> Maybe Text
isp) (\s :: IpOrganizationDetails
s@IpOrganizationDetails' {} Maybe Text
a -> IpOrganizationDetails
s {$sel:isp:IpOrganizationDetails' :: Maybe Text
isp = Maybe Text
a} :: IpOrganizationDetails)

instance Core.FromJSON IpOrganizationDetails where
  parseJSON :: Value -> Parser IpOrganizationDetails
parseJSON =
    String
-> (Object -> Parser IpOrganizationDetails)
-> Value
-> Parser IpOrganizationDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IpOrganizationDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Int -> Maybe Text -> IpOrganizationDetails
IpOrganizationDetails'
            (Maybe Text
 -> Maybe Text -> Maybe Int -> Maybe Text -> IpOrganizationDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Int -> Maybe Text -> IpOrganizationDetails)
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
"Org")
            Parser
  (Maybe Text -> Maybe Int -> Maybe Text -> IpOrganizationDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> Maybe Text -> IpOrganizationDetails)
forall (f :: * -> *) a b. Applicative f => 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
"AsnOrg")
            Parser (Maybe Int -> Maybe Text -> IpOrganizationDetails)
-> Parser (Maybe Int)
-> Parser (Maybe Text -> IpOrganizationDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Asn")
            Parser (Maybe Text -> IpOrganizationDetails)
-> Parser (Maybe Text) -> Parser IpOrganizationDetails
forall (f :: * -> *) a b. Applicative f => 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
"Isp")
      )

instance Prelude.Hashable IpOrganizationDetails

instance Prelude.NFData IpOrganizationDetails

instance Core.ToJSON IpOrganizationDetails where
  toJSON :: IpOrganizationDetails -> Value
toJSON IpOrganizationDetails' {Maybe Int
Maybe Text
isp :: Maybe Text
asn :: Maybe Int
asnOrg :: Maybe Text
org :: Maybe Text
$sel:isp:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
$sel:asn:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Int
$sel:asnOrg:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
$sel:org:IpOrganizationDetails' :: IpOrganizationDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Org" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
org,
            (Text
"AsnOrg" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
asnOrg,
            (Text
"Asn" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
asn,
            (Text
"Isp" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
isp
          ]
      )