{-# 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.ElasticSearch.AssociatePackage
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a package with an Amazon ES domain.
module Amazonka.ElasticSearch.AssociatePackage
  ( -- * Creating a Request
    AssociatePackage (..),
    newAssociatePackage,

    -- * Request Lenses
    associatePackage_packageID,
    associatePackage_domainName,

    -- * Destructuring the Response
    AssociatePackageResponse (..),
    newAssociatePackageResponse,

    -- * Response Lenses
    associatePackageResponse_domainPackageDetails,
    associatePackageResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'AssociatePackage' 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', 'associatePackage_packageID' - Internal ID of the package that you want to associate with a domain. Use
-- @DescribePackages@ to find this value.
--
-- 'domainName', 'associatePackage_domainName' - Name of the domain that you want to associate the package with.
newAssociatePackage ::
  -- | 'packageID'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  AssociatePackage
newAssociatePackage :: Text -> Text -> AssociatePackage
newAssociatePackage Text
pPackageID_ Text
pDomainName_ =
  AssociatePackage'
    { $sel:packageID:AssociatePackage' :: Text
packageID = Text
pPackageID_,
      $sel:domainName:AssociatePackage' :: Text
domainName = Text
pDomainName_
    }

-- | Internal ID of the package that you want to associate with a domain. Use
-- @DescribePackages@ to find this value.
associatePackage_packageID :: Lens.Lens' AssociatePackage Prelude.Text
associatePackage_packageID :: Lens' AssociatePackage Text
associatePackage_packageID = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePackage' {Text
packageID :: Text
$sel:packageID:AssociatePackage' :: AssociatePackage -> Text
packageID} -> Text
packageID) (\s :: AssociatePackage
s@AssociatePackage' {} Text
a -> AssociatePackage
s {$sel:packageID:AssociatePackage' :: Text
packageID = Text
a} :: AssociatePackage)

-- | Name of the domain that you want to associate the package with.
associatePackage_domainName :: Lens.Lens' AssociatePackage Prelude.Text
associatePackage_domainName :: Lens' AssociatePackage Text
associatePackage_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePackage' {Text
domainName :: Text
$sel:domainName:AssociatePackage' :: AssociatePackage -> Text
domainName} -> Text
domainName) (\s :: AssociatePackage
s@AssociatePackage' {} Text
a -> AssociatePackage
s {$sel:domainName:AssociatePackage' :: Text
domainName = Text
a} :: AssociatePackage)

instance Core.AWSRequest AssociatePackage where
  type
    AWSResponse AssociatePackage =
      AssociatePackageResponse
  request :: (Service -> Service)
-> AssociatePackage -> Request AssociatePackage
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociatePackage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AssociatePackage)))
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 ->
          Maybe DomainPackageDetails -> Int -> AssociatePackageResponse
AssociatePackageResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DomainPackageDetails")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable AssociatePackage where
  hashWithSalt :: Int -> AssociatePackage -> Int
hashWithSalt Int
_salt AssociatePackage' {Text
domainName :: Text
packageID :: Text
$sel:domainName:AssociatePackage' :: AssociatePackage -> Text
$sel:packageID:AssociatePackage' :: AssociatePackage -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
packageID
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData AssociatePackage where
  rnf :: AssociatePackage -> ()
rnf AssociatePackage' {Text
domainName :: Text
packageID :: Text
$sel:domainName:AssociatePackage' :: AssociatePackage -> Text
$sel:packageID:AssociatePackage' :: AssociatePackage -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
packageID
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

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

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

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

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

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

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

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

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

instance Prelude.NFData AssociatePackageResponse where
  rnf :: AssociatePackageResponse -> ()
rnf AssociatePackageResponse' {Int
Maybe DomainPackageDetails
httpStatus :: Int
domainPackageDetails :: Maybe DomainPackageDetails
$sel:httpStatus:AssociatePackageResponse' :: AssociatePackageResponse -> Int
$sel:domainPackageDetails:AssociatePackageResponse' :: AssociatePackageResponse -> Maybe DomainPackageDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DomainPackageDetails
domainPackageDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus