{-# 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.LicenseManager.GetLicenseUsage
-- 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)
--
-- Gets detailed information about the usage of the specified license.
module Amazonka.LicenseManager.GetLicenseUsage
  ( -- * Creating a Request
    GetLicenseUsage (..),
    newGetLicenseUsage,

    -- * Request Lenses
    getLicenseUsage_licenseArn,

    -- * Destructuring the Response
    GetLicenseUsageResponse (..),
    newGetLicenseUsageResponse,

    -- * Response Lenses
    getLicenseUsageResponse_licenseUsage,
    getLicenseUsageResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetLicenseUsage' smart constructor.
data GetLicenseUsage = GetLicenseUsage'
  { -- | Amazon Resource Name (ARN) of the license.
    GetLicenseUsage -> Text
licenseArn :: Prelude.Text
  }
  deriving (GetLicenseUsage -> GetLicenseUsage -> Bool
(GetLicenseUsage -> GetLicenseUsage -> Bool)
-> (GetLicenseUsage -> GetLicenseUsage -> Bool)
-> Eq GetLicenseUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLicenseUsage -> GetLicenseUsage -> Bool
$c/= :: GetLicenseUsage -> GetLicenseUsage -> Bool
== :: GetLicenseUsage -> GetLicenseUsage -> Bool
$c== :: GetLicenseUsage -> GetLicenseUsage -> Bool
Prelude.Eq, ReadPrec [GetLicenseUsage]
ReadPrec GetLicenseUsage
Int -> ReadS GetLicenseUsage
ReadS [GetLicenseUsage]
(Int -> ReadS GetLicenseUsage)
-> ReadS [GetLicenseUsage]
-> ReadPrec GetLicenseUsage
-> ReadPrec [GetLicenseUsage]
-> Read GetLicenseUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLicenseUsage]
$creadListPrec :: ReadPrec [GetLicenseUsage]
readPrec :: ReadPrec GetLicenseUsage
$creadPrec :: ReadPrec GetLicenseUsage
readList :: ReadS [GetLicenseUsage]
$creadList :: ReadS [GetLicenseUsage]
readsPrec :: Int -> ReadS GetLicenseUsage
$creadsPrec :: Int -> ReadS GetLicenseUsage
Prelude.Read, Int -> GetLicenseUsage -> ShowS
[GetLicenseUsage] -> ShowS
GetLicenseUsage -> String
(Int -> GetLicenseUsage -> ShowS)
-> (GetLicenseUsage -> String)
-> ([GetLicenseUsage] -> ShowS)
-> Show GetLicenseUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLicenseUsage] -> ShowS
$cshowList :: [GetLicenseUsage] -> ShowS
show :: GetLicenseUsage -> String
$cshow :: GetLicenseUsage -> String
showsPrec :: Int -> GetLicenseUsage -> ShowS
$cshowsPrec :: Int -> GetLicenseUsage -> ShowS
Prelude.Show, (forall x. GetLicenseUsage -> Rep GetLicenseUsage x)
-> (forall x. Rep GetLicenseUsage x -> GetLicenseUsage)
-> Generic GetLicenseUsage
forall x. Rep GetLicenseUsage x -> GetLicenseUsage
forall x. GetLicenseUsage -> Rep GetLicenseUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLicenseUsage x -> GetLicenseUsage
$cfrom :: forall x. GetLicenseUsage -> Rep GetLicenseUsage x
Prelude.Generic)

-- |
-- Create a value of 'GetLicenseUsage' 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:
--
-- 'licenseArn', 'getLicenseUsage_licenseArn' - Amazon Resource Name (ARN) of the license.
newGetLicenseUsage ::
  -- | 'licenseArn'
  Prelude.Text ->
  GetLicenseUsage
newGetLicenseUsage :: Text -> GetLicenseUsage
newGetLicenseUsage Text
pLicenseArn_ =
  GetLicenseUsage' :: Text -> GetLicenseUsage
GetLicenseUsage' {$sel:licenseArn:GetLicenseUsage' :: Text
licenseArn = Text
pLicenseArn_}

-- | Amazon Resource Name (ARN) of the license.
getLicenseUsage_licenseArn :: Lens.Lens' GetLicenseUsage Prelude.Text
getLicenseUsage_licenseArn :: (Text -> f Text) -> GetLicenseUsage -> f GetLicenseUsage
getLicenseUsage_licenseArn = (GetLicenseUsage -> Text)
-> (GetLicenseUsage -> Text -> GetLicenseUsage)
-> Lens GetLicenseUsage GetLicenseUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLicenseUsage' {Text
licenseArn :: Text
$sel:licenseArn:GetLicenseUsage' :: GetLicenseUsage -> Text
licenseArn} -> Text
licenseArn) (\s :: GetLicenseUsage
s@GetLicenseUsage' {} Text
a -> GetLicenseUsage
s {$sel:licenseArn:GetLicenseUsage' :: Text
licenseArn = Text
a} :: GetLicenseUsage)

instance Core.AWSRequest GetLicenseUsage where
  type
    AWSResponse GetLicenseUsage =
      GetLicenseUsageResponse
  request :: GetLicenseUsage -> Request GetLicenseUsage
request = Service -> GetLicenseUsage -> Request GetLicenseUsage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLicenseUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLicenseUsage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLicenseUsage))
-> Logger
-> Service
-> Proxy GetLicenseUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLicenseUsage)))
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 LicenseUsage -> Int -> GetLicenseUsageResponse
GetLicenseUsageResponse'
            (Maybe LicenseUsage -> Int -> GetLicenseUsageResponse)
-> Either String (Maybe LicenseUsage)
-> Either String (Int -> GetLicenseUsageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe LicenseUsage)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LicenseUsage")
            Either String (Int -> GetLicenseUsageResponse)
-> Either String Int -> Either String GetLicenseUsageResponse
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 GetLicenseUsage

instance Prelude.NFData GetLicenseUsage

instance Core.ToHeaders GetLicenseUsage where
  toHeaders :: GetLicenseUsage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetLicenseUsage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSLicenseManager.GetLicenseUsage" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetLicenseUsage where
  toJSON :: GetLicenseUsage -> Value
toJSON GetLicenseUsage' {Text
licenseArn :: Text
$sel:licenseArn:GetLicenseUsage' :: GetLicenseUsage -> 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
"LicenseArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
licenseArn)]
      )

instance Core.ToPath GetLicenseUsage where
  toPath :: GetLicenseUsage -> ByteString
toPath = ByteString -> GetLicenseUsage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetLicenseUsage where
  toQuery :: GetLicenseUsage -> QueryString
toQuery = QueryString -> GetLicenseUsage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetLicenseUsageResponse' smart constructor.
data GetLicenseUsageResponse = GetLicenseUsageResponse'
  { -- | License usage details.
    GetLicenseUsageResponse -> Maybe LicenseUsage
licenseUsage :: Prelude.Maybe LicenseUsage,
    -- | The response's http status code.
    GetLicenseUsageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool
(GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool)
-> (GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool)
-> Eq GetLicenseUsageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool
$c/= :: GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool
== :: GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool
$c== :: GetLicenseUsageResponse -> GetLicenseUsageResponse -> Bool
Prelude.Eq, ReadPrec [GetLicenseUsageResponse]
ReadPrec GetLicenseUsageResponse
Int -> ReadS GetLicenseUsageResponse
ReadS [GetLicenseUsageResponse]
(Int -> ReadS GetLicenseUsageResponse)
-> ReadS [GetLicenseUsageResponse]
-> ReadPrec GetLicenseUsageResponse
-> ReadPrec [GetLicenseUsageResponse]
-> Read GetLicenseUsageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLicenseUsageResponse]
$creadListPrec :: ReadPrec [GetLicenseUsageResponse]
readPrec :: ReadPrec GetLicenseUsageResponse
$creadPrec :: ReadPrec GetLicenseUsageResponse
readList :: ReadS [GetLicenseUsageResponse]
$creadList :: ReadS [GetLicenseUsageResponse]
readsPrec :: Int -> ReadS GetLicenseUsageResponse
$creadsPrec :: Int -> ReadS GetLicenseUsageResponse
Prelude.Read, Int -> GetLicenseUsageResponse -> ShowS
[GetLicenseUsageResponse] -> ShowS
GetLicenseUsageResponse -> String
(Int -> GetLicenseUsageResponse -> ShowS)
-> (GetLicenseUsageResponse -> String)
-> ([GetLicenseUsageResponse] -> ShowS)
-> Show GetLicenseUsageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLicenseUsageResponse] -> ShowS
$cshowList :: [GetLicenseUsageResponse] -> ShowS
show :: GetLicenseUsageResponse -> String
$cshow :: GetLicenseUsageResponse -> String
showsPrec :: Int -> GetLicenseUsageResponse -> ShowS
$cshowsPrec :: Int -> GetLicenseUsageResponse -> ShowS
Prelude.Show, (forall x.
 GetLicenseUsageResponse -> Rep GetLicenseUsageResponse x)
-> (forall x.
    Rep GetLicenseUsageResponse x -> GetLicenseUsageResponse)
-> Generic GetLicenseUsageResponse
forall x. Rep GetLicenseUsageResponse x -> GetLicenseUsageResponse
forall x. GetLicenseUsageResponse -> Rep GetLicenseUsageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLicenseUsageResponse x -> GetLicenseUsageResponse
$cfrom :: forall x. GetLicenseUsageResponse -> Rep GetLicenseUsageResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetLicenseUsageResponse' 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:
--
-- 'licenseUsage', 'getLicenseUsageResponse_licenseUsage' - License usage details.
--
-- 'httpStatus', 'getLicenseUsageResponse_httpStatus' - The response's http status code.
newGetLicenseUsageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetLicenseUsageResponse
newGetLicenseUsageResponse :: Int -> GetLicenseUsageResponse
newGetLicenseUsageResponse Int
pHttpStatus_ =
  GetLicenseUsageResponse' :: Maybe LicenseUsage -> Int -> GetLicenseUsageResponse
GetLicenseUsageResponse'
    { $sel:licenseUsage:GetLicenseUsageResponse' :: Maybe LicenseUsage
licenseUsage =
        Maybe LicenseUsage
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetLicenseUsageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | License usage details.
getLicenseUsageResponse_licenseUsage :: Lens.Lens' GetLicenseUsageResponse (Prelude.Maybe LicenseUsage)
getLicenseUsageResponse_licenseUsage :: (Maybe LicenseUsage -> f (Maybe LicenseUsage))
-> GetLicenseUsageResponse -> f GetLicenseUsageResponse
getLicenseUsageResponse_licenseUsage = (GetLicenseUsageResponse -> Maybe LicenseUsage)
-> (GetLicenseUsageResponse
    -> Maybe LicenseUsage -> GetLicenseUsageResponse)
-> Lens
     GetLicenseUsageResponse
     GetLicenseUsageResponse
     (Maybe LicenseUsage)
     (Maybe LicenseUsage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLicenseUsageResponse' {Maybe LicenseUsage
licenseUsage :: Maybe LicenseUsage
$sel:licenseUsage:GetLicenseUsageResponse' :: GetLicenseUsageResponse -> Maybe LicenseUsage
licenseUsage} -> Maybe LicenseUsage
licenseUsage) (\s :: GetLicenseUsageResponse
s@GetLicenseUsageResponse' {} Maybe LicenseUsage
a -> GetLicenseUsageResponse
s {$sel:licenseUsage:GetLicenseUsageResponse' :: Maybe LicenseUsage
licenseUsage = Maybe LicenseUsage
a} :: GetLicenseUsageResponse)

-- | The response's http status code.
getLicenseUsageResponse_httpStatus :: Lens.Lens' GetLicenseUsageResponse Prelude.Int
getLicenseUsageResponse_httpStatus :: (Int -> f Int)
-> GetLicenseUsageResponse -> f GetLicenseUsageResponse
getLicenseUsageResponse_httpStatus = (GetLicenseUsageResponse -> Int)
-> (GetLicenseUsageResponse -> Int -> GetLicenseUsageResponse)
-> Lens GetLicenseUsageResponse GetLicenseUsageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLicenseUsageResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetLicenseUsageResponse' :: GetLicenseUsageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetLicenseUsageResponse
s@GetLicenseUsageResponse' {} Int
a -> GetLicenseUsageResponse
s {$sel:httpStatus:GetLicenseUsageResponse' :: Int
httpStatus = Int
a} :: GetLicenseUsageResponse)

instance Prelude.NFData GetLicenseUsageResponse