{-# 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.OpenSearch.DissociatePackage
-- 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)
--
-- Dissociates a package from the Amazon OpenSearch Service domain.
module Amazonka.OpenSearch.DissociatePackage
  ( -- * Creating a Request
    DissociatePackage (..),
    newDissociatePackage,

    -- * Request Lenses
    dissociatePackage_packageID,
    dissociatePackage_domainName,

    -- * Destructuring the Response
    DissociatePackageResponse (..),
    newDissociatePackageResponse,

    -- * Response Lenses
    dissociatePackageResponse_domainPackageDetails,
    dissociatePackageResponse_httpStatus,
  )
where

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

-- | Container for the request parameters to the @ DissociatePackage @
-- operation.
--
-- /See:/ 'newDissociatePackage' smart constructor.
data DissociatePackage = DissociatePackage'
  { -- | The internal ID of the package to associate with a domain. Use
    -- @DescribePackages@ to find this value.
    DissociatePackage -> Text
packageID :: Prelude.Text,
    -- | The name of the domain to associate the package with.
    DissociatePackage -> Text
domainName :: Prelude.Text
  }
  deriving (DissociatePackage -> DissociatePackage -> Bool
(DissociatePackage -> DissociatePackage -> Bool)
-> (DissociatePackage -> DissociatePackage -> Bool)
-> Eq DissociatePackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DissociatePackage -> DissociatePackage -> Bool
$c/= :: DissociatePackage -> DissociatePackage -> Bool
== :: DissociatePackage -> DissociatePackage -> Bool
$c== :: DissociatePackage -> DissociatePackage -> Bool
Prelude.Eq, ReadPrec [DissociatePackage]
ReadPrec DissociatePackage
Int -> ReadS DissociatePackage
ReadS [DissociatePackage]
(Int -> ReadS DissociatePackage)
-> ReadS [DissociatePackage]
-> ReadPrec DissociatePackage
-> ReadPrec [DissociatePackage]
-> Read DissociatePackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DissociatePackage]
$creadListPrec :: ReadPrec [DissociatePackage]
readPrec :: ReadPrec DissociatePackage
$creadPrec :: ReadPrec DissociatePackage
readList :: ReadS [DissociatePackage]
$creadList :: ReadS [DissociatePackage]
readsPrec :: Int -> ReadS DissociatePackage
$creadsPrec :: Int -> ReadS DissociatePackage
Prelude.Read, Int -> DissociatePackage -> ShowS
[DissociatePackage] -> ShowS
DissociatePackage -> String
(Int -> DissociatePackage -> ShowS)
-> (DissociatePackage -> String)
-> ([DissociatePackage] -> ShowS)
-> Show DissociatePackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DissociatePackage] -> ShowS
$cshowList :: [DissociatePackage] -> ShowS
show :: DissociatePackage -> String
$cshow :: DissociatePackage -> String
showsPrec :: Int -> DissociatePackage -> ShowS
$cshowsPrec :: Int -> DissociatePackage -> ShowS
Prelude.Show, (forall x. DissociatePackage -> Rep DissociatePackage x)
-> (forall x. Rep DissociatePackage x -> DissociatePackage)
-> Generic DissociatePackage
forall x. Rep DissociatePackage x -> DissociatePackage
forall x. DissociatePackage -> Rep DissociatePackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DissociatePackage x -> DissociatePackage
$cfrom :: forall x. DissociatePackage -> Rep DissociatePackage x
Prelude.Generic)

-- |
-- Create a value of 'DissociatePackage' 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:
--
-- 'packageID', 'dissociatePackage_packageID' - The internal ID of the package to associate with a domain. Use
-- @DescribePackages@ to find this value.
--
-- 'domainName', 'dissociatePackage_domainName' - The name of the domain to associate the package with.
newDissociatePackage ::
  -- | 'packageID'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  DissociatePackage
newDissociatePackage :: Text -> Text -> DissociatePackage
newDissociatePackage Text
pPackageID_ Text
pDomainName_ =
  DissociatePackage' :: Text -> Text -> DissociatePackage
DissociatePackage'
    { $sel:packageID:DissociatePackage' :: Text
packageID = Text
pPackageID_,
      $sel:domainName:DissociatePackage' :: Text
domainName = Text
pDomainName_
    }

-- | The internal ID of the package to associate with a domain. Use
-- @DescribePackages@ to find this value.
dissociatePackage_packageID :: Lens.Lens' DissociatePackage Prelude.Text
dissociatePackage_packageID :: (Text -> f Text) -> DissociatePackage -> f DissociatePackage
dissociatePackage_packageID = (DissociatePackage -> Text)
-> (DissociatePackage -> Text -> DissociatePackage)
-> Lens DissociatePackage DissociatePackage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DissociatePackage' {Text
packageID :: Text
$sel:packageID:DissociatePackage' :: DissociatePackage -> Text
packageID} -> Text
packageID) (\s :: DissociatePackage
s@DissociatePackage' {} Text
a -> DissociatePackage
s {$sel:packageID:DissociatePackage' :: Text
packageID = Text
a} :: DissociatePackage)

-- | The name of the domain to associate the package with.
dissociatePackage_domainName :: Lens.Lens' DissociatePackage Prelude.Text
dissociatePackage_domainName :: (Text -> f Text) -> DissociatePackage -> f DissociatePackage
dissociatePackage_domainName = (DissociatePackage -> Text)
-> (DissociatePackage -> Text -> DissociatePackage)
-> Lens DissociatePackage DissociatePackage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DissociatePackage' {Text
domainName :: Text
$sel:domainName:DissociatePackage' :: DissociatePackage -> Text
domainName} -> Text
domainName) (\s :: DissociatePackage
s@DissociatePackage' {} Text
a -> DissociatePackage
s {$sel:domainName:DissociatePackage' :: Text
domainName = Text
a} :: DissociatePackage)

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

instance Prelude.NFData DissociatePackage

instance Core.ToHeaders DissociatePackage where
  toHeaders :: DissociatePackage -> ResponseHeaders
toHeaders = ResponseHeaders -> DissociatePackage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON DissociatePackage where
  toJSON :: DissociatePackage -> Value
toJSON = Value -> DissociatePackage -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath DissociatePackage where
  toPath :: DissociatePackage -> ByteString
toPath DissociatePackage' {Text
domainName :: Text
packageID :: Text
$sel:domainName:DissociatePackage' :: DissociatePackage -> Text
$sel:packageID:DissociatePackage' :: DissociatePackage -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2021-01-01/packages/dissociate/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
packageID,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName
      ]

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

-- | Container for the response returned by @ DissociatePackage @ operation.
--
-- /See:/ 'newDissociatePackageResponse' smart constructor.
data DissociatePackageResponse = DissociatePackageResponse'
  { -- | @DomainPackageDetails@
    DissociatePackageResponse -> Maybe DomainPackageDetails
domainPackageDetails :: Prelude.Maybe DomainPackageDetails,
    -- | The response's http status code.
    DissociatePackageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DissociatePackageResponse -> DissociatePackageResponse -> Bool
(DissociatePackageResponse -> DissociatePackageResponse -> Bool)
-> (DissociatePackageResponse -> DissociatePackageResponse -> Bool)
-> Eq DissociatePackageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DissociatePackageResponse -> DissociatePackageResponse -> Bool
$c/= :: DissociatePackageResponse -> DissociatePackageResponse -> Bool
== :: DissociatePackageResponse -> DissociatePackageResponse -> Bool
$c== :: DissociatePackageResponse -> DissociatePackageResponse -> Bool
Prelude.Eq, ReadPrec [DissociatePackageResponse]
ReadPrec DissociatePackageResponse
Int -> ReadS DissociatePackageResponse
ReadS [DissociatePackageResponse]
(Int -> ReadS DissociatePackageResponse)
-> ReadS [DissociatePackageResponse]
-> ReadPrec DissociatePackageResponse
-> ReadPrec [DissociatePackageResponse]
-> Read DissociatePackageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DissociatePackageResponse]
$creadListPrec :: ReadPrec [DissociatePackageResponse]
readPrec :: ReadPrec DissociatePackageResponse
$creadPrec :: ReadPrec DissociatePackageResponse
readList :: ReadS [DissociatePackageResponse]
$creadList :: ReadS [DissociatePackageResponse]
readsPrec :: Int -> ReadS DissociatePackageResponse
$creadsPrec :: Int -> ReadS DissociatePackageResponse
Prelude.Read, Int -> DissociatePackageResponse -> ShowS
[DissociatePackageResponse] -> ShowS
DissociatePackageResponse -> String
(Int -> DissociatePackageResponse -> ShowS)
-> (DissociatePackageResponse -> String)
-> ([DissociatePackageResponse] -> ShowS)
-> Show DissociatePackageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DissociatePackageResponse] -> ShowS
$cshowList :: [DissociatePackageResponse] -> ShowS
show :: DissociatePackageResponse -> String
$cshow :: DissociatePackageResponse -> String
showsPrec :: Int -> DissociatePackageResponse -> ShowS
$cshowsPrec :: Int -> DissociatePackageResponse -> ShowS
Prelude.Show, (forall x.
 DissociatePackageResponse -> Rep DissociatePackageResponse x)
-> (forall x.
    Rep DissociatePackageResponse x -> DissociatePackageResponse)
-> Generic DissociatePackageResponse
forall x.
Rep DissociatePackageResponse x -> DissociatePackageResponse
forall x.
DissociatePackageResponse -> Rep DissociatePackageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DissociatePackageResponse x -> DissociatePackageResponse
$cfrom :: forall x.
DissociatePackageResponse -> Rep DissociatePackageResponse x
Prelude.Generic)

-- |
-- Create a value of 'DissociatePackageResponse' 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:
--
-- 'domainPackageDetails', 'dissociatePackageResponse_domainPackageDetails' - @DomainPackageDetails@
--
-- 'httpStatus', 'dissociatePackageResponse_httpStatus' - The response's http status code.
newDissociatePackageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DissociatePackageResponse
newDissociatePackageResponse :: Int -> DissociatePackageResponse
newDissociatePackageResponse Int
pHttpStatus_ =
  DissociatePackageResponse' :: Maybe DomainPackageDetails -> Int -> DissociatePackageResponse
DissociatePackageResponse'
    { $sel:domainPackageDetails:DissociatePackageResponse' :: Maybe DomainPackageDetails
domainPackageDetails =
        Maybe DomainPackageDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DissociatePackageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | @DomainPackageDetails@
dissociatePackageResponse_domainPackageDetails :: Lens.Lens' DissociatePackageResponse (Prelude.Maybe DomainPackageDetails)
dissociatePackageResponse_domainPackageDetails :: (Maybe DomainPackageDetails -> f (Maybe DomainPackageDetails))
-> DissociatePackageResponse -> f DissociatePackageResponse
dissociatePackageResponse_domainPackageDetails = (DissociatePackageResponse -> Maybe DomainPackageDetails)
-> (DissociatePackageResponse
    -> Maybe DomainPackageDetails -> DissociatePackageResponse)
-> Lens
     DissociatePackageResponse
     DissociatePackageResponse
     (Maybe DomainPackageDetails)
     (Maybe DomainPackageDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DissociatePackageResponse' {Maybe DomainPackageDetails
domainPackageDetails :: Maybe DomainPackageDetails
$sel:domainPackageDetails:DissociatePackageResponse' :: DissociatePackageResponse -> Maybe DomainPackageDetails
domainPackageDetails} -> Maybe DomainPackageDetails
domainPackageDetails) (\s :: DissociatePackageResponse
s@DissociatePackageResponse' {} Maybe DomainPackageDetails
a -> DissociatePackageResponse
s {$sel:domainPackageDetails:DissociatePackageResponse' :: Maybe DomainPackageDetails
domainPackageDetails = Maybe DomainPackageDetails
a} :: DissociatePackageResponse)

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

instance Prelude.NFData DissociatePackageResponse