{-# 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-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)
--
-- 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 Amazonka.Grafana.Types
import qualified Amazonka.Lens as Lens
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
(DisassociateLicense -> DisassociateLicense -> Bool)
-> (DisassociateLicense -> DisassociateLicense -> Bool)
-> Eq DisassociateLicense
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]
(Int -> ReadS DisassociateLicense)
-> ReadS [DisassociateLicense]
-> ReadPrec DisassociateLicense
-> ReadPrec [DisassociateLicense]
-> Read 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
(Int -> DisassociateLicense -> ShowS)
-> (DisassociateLicense -> String)
-> ([DisassociateLicense] -> ShowS)
-> Show DisassociateLicense
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. DisassociateLicense -> Rep DisassociateLicense x)
-> (forall x. Rep DisassociateLicense x -> DisassociateLicense)
-> Generic DisassociateLicense
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' :: LicenseType -> Text -> DisassociateLicense
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 :: (LicenseType -> f LicenseType)
-> DisassociateLicense -> f DisassociateLicense
disassociateLicense_licenseType = (DisassociateLicense -> LicenseType)
-> (DisassociateLicense -> LicenseType -> DisassociateLicense)
-> Lens
     DisassociateLicense DisassociateLicense LicenseType 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 :: (Text -> f Text) -> DisassociateLicense -> f DisassociateLicense
disassociateLicense_workspaceId = (DisassociateLicense -> Text)
-> (DisassociateLicense -> Text -> DisassociateLicense)
-> Lens DisassociateLicense DisassociateLicense Text Text
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 :: DisassociateLicense -> Request DisassociateLicense
request = Service -> DisassociateLicense -> Request DisassociateLicense
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateLicense
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateLicense)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisassociateLicense))
-> Logger
-> Service
-> Proxy DisassociateLicense
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateLicense)))
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 ->
          Int -> WorkspaceDescription -> DisassociateLicenseResponse
DisassociateLicenseResponse'
            (Int -> WorkspaceDescription -> DisassociateLicenseResponse)
-> Either String Int
-> Either
     String (WorkspaceDescription -> DisassociateLicenseResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (WorkspaceDescription -> DisassociateLicenseResponse)
-> Either String WorkspaceDescription
-> Either String DisassociateLicenseResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String WorkspaceDescription
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"workspace")
      )

instance Prelude.Hashable DisassociateLicense

instance Prelude.NFData DisassociateLicense

instance Core.ToHeaders DisassociateLicense where
  toHeaders :: DisassociateLicense -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateLicense -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DisassociateLicense where
  toPath :: DisassociateLicense -> ByteString
toPath DisassociateLicense' {Text
LicenseType
workspaceId :: Text
licenseType :: LicenseType
$sel:workspaceId:DisassociateLicense' :: DisassociateLicense -> Text
$sel:licenseType:DisassociateLicense' :: DisassociateLicense -> LicenseType
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workspaces/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workspaceId,
        ByteString
"/licenses/",
        LicenseType -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS LicenseType
licenseType
      ]

instance Core.ToQuery DisassociateLicense where
  toQuery :: DisassociateLicense -> QueryString
toQuery = QueryString -> DisassociateLicense -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DisassociateLicenseResponse
 -> DisassociateLicenseResponse -> Bool)
-> (DisassociateLicenseResponse
    -> DisassociateLicenseResponse -> Bool)
-> Eq DisassociateLicenseResponse
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
(Int -> DisassociateLicenseResponse -> ShowS)
-> (DisassociateLicenseResponse -> String)
-> ([DisassociateLicenseResponse] -> ShowS)
-> Show DisassociateLicenseResponse
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.
 DisassociateLicenseResponse -> Rep DisassociateLicenseResponse x)
-> (forall x.
    Rep DisassociateLicenseResponse x -> DisassociateLicenseResponse)
-> Generic DisassociateLicenseResponse
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' :: Int -> WorkspaceDescription -> DisassociateLicenseResponse
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 :: (Int -> f Int)
-> DisassociateLicenseResponse -> f DisassociateLicenseResponse
disassociateLicenseResponse_httpStatus = (DisassociateLicenseResponse -> Int)
-> (DisassociateLicenseResponse
    -> Int -> DisassociateLicenseResponse)
-> Lens
     DisassociateLicenseResponse DisassociateLicenseResponse Int Int
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 :: (WorkspaceDescription -> f WorkspaceDescription)
-> DisassociateLicenseResponse -> f DisassociateLicenseResponse
disassociateLicenseResponse_workspace = (DisassociateLicenseResponse -> WorkspaceDescription)
-> (DisassociateLicenseResponse
    -> WorkspaceDescription -> DisassociateLicenseResponse)
-> Lens
     DisassociateLicenseResponse
     DisassociateLicenseResponse
     WorkspaceDescription
     WorkspaceDescription
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