{-# 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.Grafana.DisassociateLicense
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes the Grafana Enterprise license from a workspace.
module Amazonka.Grafana.DisassociateLicense
  ( -- * Creating a Request
    DisassociateLicense (..),
    newDisassociateLicense,

    -- * Request Lenses
    disassociateLicense_licenseType,
    disassociateLicense_workspaceId,

    -- * Destructuring the Response
    DisassociateLicenseResponse (..),
    newDisassociateLicenseResponse,

    -- * Response Lenses
    disassociateLicenseResponse_httpStatus,
    disassociateLicenseResponse_workspace,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Grafana.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDisassociateLicense' smart constructor.
data DisassociateLicense = DisassociateLicense'
  { -- | The type of license to remove from the workspace.
    DisassociateLicense -> LicenseType
licenseType :: LicenseType,
    -- | The ID of the workspace to remove the Grafana Enterprise license from.
    DisassociateLicense -> Text
workspaceId :: Prelude.Text
  }
  deriving (DisassociateLicense -> DisassociateLicense -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateLicense -> DisassociateLicense -> Bool
$c/= :: DisassociateLicense -> DisassociateLicense -> Bool
== :: DisassociateLicense -> DisassociateLicense -> Bool
$c== :: DisassociateLicense -> DisassociateLicense -> Bool
Prelude.Eq, ReadPrec [DisassociateLicense]
ReadPrec DisassociateLicense
Int -> ReadS DisassociateLicense
ReadS [DisassociateLicense]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateLicense]
$creadListPrec :: ReadPrec [DisassociateLicense]
readPrec :: ReadPrec DisassociateLicense
$creadPrec :: ReadPrec DisassociateLicense
readList :: ReadS [DisassociateLicense]
$creadList :: ReadS [DisassociateLicense]
readsPrec :: Int -> ReadS DisassociateLicense
$creadsPrec :: Int -> ReadS DisassociateLicense
Prelude.Read, Int -> DisassociateLicense -> ShowS
[DisassociateLicense] -> ShowS
DisassociateLicense -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateLicense] -> ShowS
$cshowList :: [DisassociateLicense] -> ShowS
show :: DisassociateLicense -> String
$cshow :: DisassociateLicense -> String
showsPrec :: Int -> DisassociateLicense -> ShowS
$cshowsPrec :: Int -> DisassociateLicense -> ShowS
Prelude.Show, forall x. Rep DisassociateLicense x -> DisassociateLicense
forall x. DisassociateLicense -> Rep DisassociateLicense x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateLicense x -> DisassociateLicense
$cfrom :: forall x. DisassociateLicense -> Rep DisassociateLicense x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateLicense' 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:
--
-- 'licenseType', 'disassociateLicense_licenseType' - The type of license to remove from the workspace.
--
-- 'workspaceId', 'disassociateLicense_workspaceId' - The ID of the workspace to remove the Grafana Enterprise license from.
newDisassociateLicense ::
  -- | 'licenseType'
  LicenseType ->
  -- | 'workspaceId'
  Prelude.Text ->
  DisassociateLicense
newDisassociateLicense :: LicenseType -> Text -> DisassociateLicense
newDisassociateLicense LicenseType
pLicenseType_ Text
pWorkspaceId_ =
  DisassociateLicense'
    { $sel:licenseType:DisassociateLicense' :: LicenseType
licenseType = LicenseType
pLicenseType_,
      $sel:workspaceId:DisassociateLicense' :: Text
workspaceId = Text
pWorkspaceId_
    }

-- | The type of license to remove from the workspace.
disassociateLicense_licenseType :: Lens.Lens' DisassociateLicense LicenseType
disassociateLicense_licenseType :: Lens' DisassociateLicense LicenseType
disassociateLicense_licenseType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateLicense' {LicenseType
licenseType :: LicenseType
$sel:licenseType:DisassociateLicense' :: DisassociateLicense -> LicenseType
licenseType} -> LicenseType
licenseType) (\s :: DisassociateLicense
s@DisassociateLicense' {} LicenseType
a -> DisassociateLicense
s {$sel:licenseType:DisassociateLicense' :: LicenseType
licenseType = LicenseType
a} :: DisassociateLicense)

-- | The ID of the workspace to remove the Grafana Enterprise license from.
disassociateLicense_workspaceId :: Lens.Lens' DisassociateLicense Prelude.Text
disassociateLicense_workspaceId :: Lens' DisassociateLicense Text
disassociateLicense_workspaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateLicense' {Text
workspaceId :: Text
$sel:workspaceId:DisassociateLicense' :: DisassociateLicense -> Text
workspaceId} -> Text
workspaceId) (\s :: DisassociateLicense
s@DisassociateLicense' {} Text
a -> DisassociateLicense
s {$sel:workspaceId:DisassociateLicense' :: Text
workspaceId = Text
a} :: DisassociateLicense)

instance Core.AWSRequest DisassociateLicense where
  type
    AWSResponse DisassociateLicense =
      DisassociateLicenseResponse
  request :: (Service -> Service)
-> DisassociateLicense -> Request DisassociateLicense
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisassociateLicense
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateLicense)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> WorkspaceDescription -> DisassociateLicenseResponse
DisassociateLicenseResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"workspace")
      )

instance Prelude.Hashable DisassociateLicense where
  hashWithSalt :: Int -> DisassociateLicense -> Int
hashWithSalt Int
_salt DisassociateLicense' {Text
LicenseType
workspaceId :: Text
licenseType :: LicenseType
$sel:workspaceId:DisassociateLicense' :: DisassociateLicense -> Text
$sel:licenseType:DisassociateLicense' :: DisassociateLicense -> LicenseType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LicenseType
licenseType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workspaceId

instance Prelude.NFData DisassociateLicense where
  rnf :: DisassociateLicense -> ()
rnf DisassociateLicense' {Text
LicenseType
workspaceId :: Text
licenseType :: LicenseType
$sel:workspaceId:DisassociateLicense' :: DisassociateLicense -> Text
$sel:licenseType:DisassociateLicense' :: DisassociateLicense -> LicenseType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf LicenseType
licenseType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
workspaceId

instance Data.ToHeaders DisassociateLicense where
  toHeaders :: DisassociateLicense -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DisassociateLicense where
  toPath :: DisassociateLicense -> ByteString
toPath DisassociateLicense' {Text
LicenseType
workspaceId :: Text
licenseType :: LicenseType
$sel:workspaceId:DisassociateLicense' :: DisassociateLicense -> Text
$sel:licenseType:DisassociateLicense' :: DisassociateLicense -> LicenseType
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workspaces/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
workspaceId,
        ByteString
"/licenses/",
        forall a. ToByteString a => a -> ByteString
Data.toBS LicenseType
licenseType
      ]

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

-- | /See:/ 'newDisassociateLicenseResponse' smart constructor.
data DisassociateLicenseResponse = DisassociateLicenseResponse'
  { -- | The response's http status code.
    DisassociateLicenseResponse -> Int
httpStatus :: Prelude.Int,
    -- | A structure containing information about the workspace.
    DisassociateLicenseResponse -> WorkspaceDescription
workspace :: WorkspaceDescription
  }
  deriving (DisassociateLicenseResponse -> DisassociateLicenseResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateLicenseResponse -> DisassociateLicenseResponse -> Bool
$c/= :: DisassociateLicenseResponse -> DisassociateLicenseResponse -> Bool
== :: DisassociateLicenseResponse -> DisassociateLicenseResponse -> Bool
$c== :: DisassociateLicenseResponse -> DisassociateLicenseResponse -> Bool
Prelude.Eq, Int -> DisassociateLicenseResponse -> ShowS
[DisassociateLicenseResponse] -> ShowS
DisassociateLicenseResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateLicenseResponse] -> ShowS
$cshowList :: [DisassociateLicenseResponse] -> ShowS
show :: DisassociateLicenseResponse -> String
$cshow :: DisassociateLicenseResponse -> String
showsPrec :: Int -> DisassociateLicenseResponse -> ShowS
$cshowsPrec :: Int -> DisassociateLicenseResponse -> ShowS
Prelude.Show, forall x.
Rep DisassociateLicenseResponse x -> DisassociateLicenseResponse
forall x.
DisassociateLicenseResponse -> Rep DisassociateLicenseResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateLicenseResponse x -> DisassociateLicenseResponse
$cfrom :: forall x.
DisassociateLicenseResponse -> Rep DisassociateLicenseResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateLicenseResponse' 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:
--
-- 'httpStatus', 'disassociateLicenseResponse_httpStatus' - The response's http status code.
--
-- 'workspace', 'disassociateLicenseResponse_workspace' - A structure containing information about the workspace.
newDisassociateLicenseResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workspace'
  WorkspaceDescription ->
  DisassociateLicenseResponse
newDisassociateLicenseResponse :: Int -> WorkspaceDescription -> DisassociateLicenseResponse
newDisassociateLicenseResponse
  Int
pHttpStatus_
  WorkspaceDescription
pWorkspace_ =
    DisassociateLicenseResponse'
      { $sel:httpStatus:DisassociateLicenseResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:workspace:DisassociateLicenseResponse' :: WorkspaceDescription
workspace = WorkspaceDescription
pWorkspace_
      }

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

-- | A structure containing information about the workspace.
disassociateLicenseResponse_workspace :: Lens.Lens' DisassociateLicenseResponse WorkspaceDescription
disassociateLicenseResponse_workspace :: Lens' DisassociateLicenseResponse WorkspaceDescription
disassociateLicenseResponse_workspace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateLicenseResponse' {WorkspaceDescription
workspace :: WorkspaceDescription
$sel:workspace:DisassociateLicenseResponse' :: DisassociateLicenseResponse -> WorkspaceDescription
workspace} -> WorkspaceDescription
workspace) (\s :: DisassociateLicenseResponse
s@DisassociateLicenseResponse' {} WorkspaceDescription
a -> DisassociateLicenseResponse
s {$sel:workspace:DisassociateLicenseResponse' :: WorkspaceDescription
workspace = WorkspaceDescription
a} :: DisassociateLicenseResponse)

instance Prelude.NFData DisassociateLicenseResponse where
  rnf :: DisassociateLicenseResponse -> ()
rnf DisassociateLicenseResponse' {Int
WorkspaceDescription
workspace :: WorkspaceDescription
httpStatus :: Int
$sel:workspace:DisassociateLicenseResponse' :: DisassociateLicenseResponse -> WorkspaceDescription
$sel:httpStatus:DisassociateLicenseResponse' :: DisassociateLicenseResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WorkspaceDescription
workspace