{-# 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.Location.AssociateTrackerConsumer
-- 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)
--
-- Creates an association between a geofence collection and a tracker
-- resource. This allows the tracker resource to communicate location data
-- to the linked geofence collection.
--
-- You can associate up to five geofence collections to each tracker
-- resource.
--
-- Currently not supported — Cross-account configurations, such as creating
-- associations between a tracker resource in one account and a geofence
-- collection in another account.
module Amazonka.Location.AssociateTrackerConsumer
  ( -- * Creating a Request
    AssociateTrackerConsumer (..),
    newAssociateTrackerConsumer,

    -- * Request Lenses
    associateTrackerConsumer_consumerArn,
    associateTrackerConsumer_trackerName,

    -- * Destructuring the Response
    AssociateTrackerConsumerResponse (..),
    newAssociateTrackerConsumerResponse,

    -- * Response Lenses
    associateTrackerConsumerResponse_httpStatus,
  )
where

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

-- | /See:/ 'newAssociateTrackerConsumer' smart constructor.
data AssociateTrackerConsumer = AssociateTrackerConsumer'
  { -- | The Amazon Resource Name (ARN) for the geofence collection to be
    -- associated to tracker resource. Used when you need to specify a resource
    -- across all AWS.
    --
    -- -   Format example:
    --     @arn:aws:geo:region:account-id:geofence-collection\/ExampleGeofenceCollectionConsumer@
    AssociateTrackerConsumer -> Text
consumerArn :: Prelude.Text,
    -- | The name of the tracker resource to be associated with a geofence
    -- collection.
    AssociateTrackerConsumer -> Text
trackerName :: Prelude.Text
  }
  deriving (AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool
(AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool)
-> (AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool)
-> Eq AssociateTrackerConsumer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool
$c/= :: AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool
== :: AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool
$c== :: AssociateTrackerConsumer -> AssociateTrackerConsumer -> Bool
Prelude.Eq, ReadPrec [AssociateTrackerConsumer]
ReadPrec AssociateTrackerConsumer
Int -> ReadS AssociateTrackerConsumer
ReadS [AssociateTrackerConsumer]
(Int -> ReadS AssociateTrackerConsumer)
-> ReadS [AssociateTrackerConsumer]
-> ReadPrec AssociateTrackerConsumer
-> ReadPrec [AssociateTrackerConsumer]
-> Read AssociateTrackerConsumer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateTrackerConsumer]
$creadListPrec :: ReadPrec [AssociateTrackerConsumer]
readPrec :: ReadPrec AssociateTrackerConsumer
$creadPrec :: ReadPrec AssociateTrackerConsumer
readList :: ReadS [AssociateTrackerConsumer]
$creadList :: ReadS [AssociateTrackerConsumer]
readsPrec :: Int -> ReadS AssociateTrackerConsumer
$creadsPrec :: Int -> ReadS AssociateTrackerConsumer
Prelude.Read, Int -> AssociateTrackerConsumer -> ShowS
[AssociateTrackerConsumer] -> ShowS
AssociateTrackerConsumer -> String
(Int -> AssociateTrackerConsumer -> ShowS)
-> (AssociateTrackerConsumer -> String)
-> ([AssociateTrackerConsumer] -> ShowS)
-> Show AssociateTrackerConsumer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateTrackerConsumer] -> ShowS
$cshowList :: [AssociateTrackerConsumer] -> ShowS
show :: AssociateTrackerConsumer -> String
$cshow :: AssociateTrackerConsumer -> String
showsPrec :: Int -> AssociateTrackerConsumer -> ShowS
$cshowsPrec :: Int -> AssociateTrackerConsumer -> ShowS
Prelude.Show, (forall x.
 AssociateTrackerConsumer -> Rep AssociateTrackerConsumer x)
-> (forall x.
    Rep AssociateTrackerConsumer x -> AssociateTrackerConsumer)
-> Generic AssociateTrackerConsumer
forall x.
Rep AssociateTrackerConsumer x -> AssociateTrackerConsumer
forall x.
AssociateTrackerConsumer -> Rep AssociateTrackerConsumer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateTrackerConsumer x -> AssociateTrackerConsumer
$cfrom :: forall x.
AssociateTrackerConsumer -> Rep AssociateTrackerConsumer x
Prelude.Generic)

-- |
-- Create a value of 'AssociateTrackerConsumer' 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:
--
-- 'consumerArn', 'associateTrackerConsumer_consumerArn' - The Amazon Resource Name (ARN) for the geofence collection to be
-- associated to tracker resource. Used when you need to specify a resource
-- across all AWS.
--
-- -   Format example:
--     @arn:aws:geo:region:account-id:geofence-collection\/ExampleGeofenceCollectionConsumer@
--
-- 'trackerName', 'associateTrackerConsumer_trackerName' - The name of the tracker resource to be associated with a geofence
-- collection.
newAssociateTrackerConsumer ::
  -- | 'consumerArn'
  Prelude.Text ->
  -- | 'trackerName'
  Prelude.Text ->
  AssociateTrackerConsumer
newAssociateTrackerConsumer :: Text -> Text -> AssociateTrackerConsumer
newAssociateTrackerConsumer
  Text
pConsumerArn_
  Text
pTrackerName_ =
    AssociateTrackerConsumer' :: Text -> Text -> AssociateTrackerConsumer
AssociateTrackerConsumer'
      { $sel:consumerArn:AssociateTrackerConsumer' :: Text
consumerArn =
          Text
pConsumerArn_,
        $sel:trackerName:AssociateTrackerConsumer' :: Text
trackerName = Text
pTrackerName_
      }

-- | The Amazon Resource Name (ARN) for the geofence collection to be
-- associated to tracker resource. Used when you need to specify a resource
-- across all AWS.
--
-- -   Format example:
--     @arn:aws:geo:region:account-id:geofence-collection\/ExampleGeofenceCollectionConsumer@
associateTrackerConsumer_consumerArn :: Lens.Lens' AssociateTrackerConsumer Prelude.Text
associateTrackerConsumer_consumerArn :: (Text -> f Text)
-> AssociateTrackerConsumer -> f AssociateTrackerConsumer
associateTrackerConsumer_consumerArn = (AssociateTrackerConsumer -> Text)
-> (AssociateTrackerConsumer -> Text -> AssociateTrackerConsumer)
-> Lens AssociateTrackerConsumer AssociateTrackerConsumer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrackerConsumer' {Text
consumerArn :: Text
$sel:consumerArn:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> Text
consumerArn} -> Text
consumerArn) (\s :: AssociateTrackerConsumer
s@AssociateTrackerConsumer' {} Text
a -> AssociateTrackerConsumer
s {$sel:consumerArn:AssociateTrackerConsumer' :: Text
consumerArn = Text
a} :: AssociateTrackerConsumer)

-- | The name of the tracker resource to be associated with a geofence
-- collection.
associateTrackerConsumer_trackerName :: Lens.Lens' AssociateTrackerConsumer Prelude.Text
associateTrackerConsumer_trackerName :: (Text -> f Text)
-> AssociateTrackerConsumer -> f AssociateTrackerConsumer
associateTrackerConsumer_trackerName = (AssociateTrackerConsumer -> Text)
-> (AssociateTrackerConsumer -> Text -> AssociateTrackerConsumer)
-> Lens AssociateTrackerConsumer AssociateTrackerConsumer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateTrackerConsumer' {Text
trackerName :: Text
$sel:trackerName:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> Text
trackerName} -> Text
trackerName) (\s :: AssociateTrackerConsumer
s@AssociateTrackerConsumer' {} Text
a -> AssociateTrackerConsumer
s {$sel:trackerName:AssociateTrackerConsumer' :: Text
trackerName = Text
a} :: AssociateTrackerConsumer)

instance Core.AWSRequest AssociateTrackerConsumer where
  type
    AWSResponse AssociateTrackerConsumer =
      AssociateTrackerConsumerResponse
  request :: AssociateTrackerConsumer -> Request AssociateTrackerConsumer
request = Service
-> AssociateTrackerConsumer -> Request AssociateTrackerConsumer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateTrackerConsumer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrackerConsumer)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateTrackerConsumer))
-> Logger
-> Service
-> Proxy AssociateTrackerConsumer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateTrackerConsumer)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateTrackerConsumerResponse
AssociateTrackerConsumerResponse'
            (Int -> AssociateTrackerConsumerResponse)
-> Either String Int
-> Either String AssociateTrackerConsumerResponse
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))
      )

instance Prelude.Hashable AssociateTrackerConsumer

instance Prelude.NFData AssociateTrackerConsumer

instance Core.ToHeaders AssociateTrackerConsumer where
  toHeaders :: AssociateTrackerConsumer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateTrackerConsumer -> 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.ToJSON AssociateTrackerConsumer where
  toJSON :: AssociateTrackerConsumer -> Value
toJSON AssociateTrackerConsumer' {Text
trackerName :: Text
consumerArn :: Text
$sel:trackerName:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> Text
$sel:consumerArn:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> 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
"ConsumerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
consumerArn)]
      )

instance Core.ToPath AssociateTrackerConsumer where
  toPath :: AssociateTrackerConsumer -> ByteString
toPath AssociateTrackerConsumer' {Text
trackerName :: Text
consumerArn :: Text
$sel:trackerName:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> Text
$sel:consumerArn:AssociateTrackerConsumer' :: AssociateTrackerConsumer -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/tracking/v0/trackers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
trackerName,
        ByteString
"/consumers"
      ]

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

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

-- |
-- Create a value of 'AssociateTrackerConsumerResponse' 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', 'associateTrackerConsumerResponse_httpStatus' - The response's http status code.
newAssociateTrackerConsumerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateTrackerConsumerResponse
newAssociateTrackerConsumerResponse :: Int -> AssociateTrackerConsumerResponse
newAssociateTrackerConsumerResponse Int
pHttpStatus_ =
  AssociateTrackerConsumerResponse' :: Int -> AssociateTrackerConsumerResponse
AssociateTrackerConsumerResponse'
    { $sel:httpStatus:AssociateTrackerConsumerResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    AssociateTrackerConsumerResponse