{-# 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.DataSync.CreateAgent
-- 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)
--
-- Activates an DataSync agent that you have deployed on your host. The
-- activation process associates your agent with your account. In the
-- activation process, you specify information such as the Amazon Web
-- Services Region that you want to activate the agent in. You activate the
-- agent in the Amazon Web Services Region where your target locations (in
-- Amazon S3 or Amazon EFS) reside. Your tasks are created in this Amazon
-- Web Services Region.
--
-- You can activate the agent in a VPC (virtual private cloud) or provide
-- the agent access to a VPC endpoint so you can run tasks without going
-- over the public internet.
--
-- You can use an agent for more than one location. If a task uses multiple
-- agents, all of them need to have status AVAILABLE for the task to run.
-- If you use multiple agents for a source location, the status of all the
-- agents must be AVAILABLE for the task to run.
--
-- Agents are automatically updated by Amazon Web Services on a regular
-- basis, using a mechanism that ensures minimal interruption to your
-- tasks.
module Amazonka.DataSync.CreateAgent
  ( -- * Creating a Request
    CreateAgent (..),
    newCreateAgent,

    -- * Request Lenses
    createAgent_securityGroupArns,
    createAgent_subnetArns,
    createAgent_agentName,
    createAgent_vpcEndpointId,
    createAgent_tags,
    createAgent_activationKey,

    -- * Destructuring the Response
    CreateAgentResponse (..),
    newCreateAgentResponse,

    -- * Response Lenses
    createAgentResponse_agentArn,
    createAgentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataSync.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

-- | CreateAgentRequest
--
-- /See:/ 'newCreateAgent' smart constructor.
data CreateAgent = CreateAgent'
  { -- | The ARNs of the security groups used to protect your data transfer task
    -- subnets. See
    -- <https://docs.aws.amazon.com/datasync/latest/userguide/API_Ec2Config.html#DataSync-Type-Ec2Config-SecurityGroupArns SecurityGroupArns>.
    CreateAgent -> Maybe (NonEmpty Text)
securityGroupArns :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The Amazon Resource Names (ARNs) of the subnets in which DataSync will
    -- create elastic network interfaces for each data transfer task. The agent
    -- that runs a task must be private. When you start a task that is
    -- associated with an agent created in a VPC, or one that has access to an
    -- IP address in a VPC, then the task is also private. In this case,
    -- DataSync creates four network interfaces for each task in your subnet.
    -- For a data transfer to work, the agent must be able to route to all
    -- these four network interfaces.
    CreateAgent -> Maybe (NonEmpty Text)
subnetArns :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name you configured for your agent. This value is a text reference
    -- that is used to identify the agent in the console.
    CreateAgent -> Maybe Text
agentName :: Prelude.Maybe Prelude.Text,
    -- | The ID of the VPC (virtual private cloud) endpoint that the agent has
    -- access to. This is the client-side VPC endpoint, also called a
    -- PrivateLink. If you don\'t have a PrivateLink VPC endpoint, see
    -- <https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html#create-endpoint-service Creating a VPC Endpoint Service Configuration>
    -- in the Amazon VPC User Guide.
    --
    -- VPC endpoint ID looks like this: @vpce-01234d5aff67890e1@.
    CreateAgent -> Maybe Text
vpcEndpointId :: Prelude.Maybe Prelude.Text,
    -- | The key-value pair that represents the tag that you want to associate
    -- with the agent. The value can be an empty string. This value helps you
    -- manage, filter, and search for your agents.
    --
    -- Valid characters for key and value are letters, spaces, and numbers
    -- representable in UTF-8 format, and the following special characters: + -
    -- = . _ : \/ \@.
    CreateAgent -> Maybe [TagListEntry]
tags :: Prelude.Maybe [TagListEntry],
    -- | Your agent activation key. You can get the activation key either by
    -- sending an HTTP GET request with redirects that enable you to get the
    -- agent IP address (port 80). Alternatively, you can get it from the
    -- DataSync console.
    --
    -- The redirect URL returned in the response provides you the activation
    -- key for your agent in the query string parameter @activationKey@. It
    -- might also include other activation-related parameters; however, these
    -- are merely defaults. The arguments you pass to this API call determine
    -- the actual configuration of your agent.
    --
    -- For more information, see Activating an Agent in the /DataSync User
    -- Guide./
    CreateAgent -> Text
activationKey :: Prelude.Text
  }
  deriving (CreateAgent -> CreateAgent -> Bool
(CreateAgent -> CreateAgent -> Bool)
-> (CreateAgent -> CreateAgent -> Bool) -> Eq CreateAgent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAgent -> CreateAgent -> Bool
$c/= :: CreateAgent -> CreateAgent -> Bool
== :: CreateAgent -> CreateAgent -> Bool
$c== :: CreateAgent -> CreateAgent -> Bool
Prelude.Eq, ReadPrec [CreateAgent]
ReadPrec CreateAgent
Int -> ReadS CreateAgent
ReadS [CreateAgent]
(Int -> ReadS CreateAgent)
-> ReadS [CreateAgent]
-> ReadPrec CreateAgent
-> ReadPrec [CreateAgent]
-> Read CreateAgent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAgent]
$creadListPrec :: ReadPrec [CreateAgent]
readPrec :: ReadPrec CreateAgent
$creadPrec :: ReadPrec CreateAgent
readList :: ReadS [CreateAgent]
$creadList :: ReadS [CreateAgent]
readsPrec :: Int -> ReadS CreateAgent
$creadsPrec :: Int -> ReadS CreateAgent
Prelude.Read, Int -> CreateAgent -> ShowS
[CreateAgent] -> ShowS
CreateAgent -> String
(Int -> CreateAgent -> ShowS)
-> (CreateAgent -> String)
-> ([CreateAgent] -> ShowS)
-> Show CreateAgent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAgent] -> ShowS
$cshowList :: [CreateAgent] -> ShowS
show :: CreateAgent -> String
$cshow :: CreateAgent -> String
showsPrec :: Int -> CreateAgent -> ShowS
$cshowsPrec :: Int -> CreateAgent -> ShowS
Prelude.Show, (forall x. CreateAgent -> Rep CreateAgent x)
-> (forall x. Rep CreateAgent x -> CreateAgent)
-> Generic CreateAgent
forall x. Rep CreateAgent x -> CreateAgent
forall x. CreateAgent -> Rep CreateAgent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAgent x -> CreateAgent
$cfrom :: forall x. CreateAgent -> Rep CreateAgent x
Prelude.Generic)

-- |
-- Create a value of 'CreateAgent' 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:
--
-- 'securityGroupArns', 'createAgent_securityGroupArns' - The ARNs of the security groups used to protect your data transfer task
-- subnets. See
-- <https://docs.aws.amazon.com/datasync/latest/userguide/API_Ec2Config.html#DataSync-Type-Ec2Config-SecurityGroupArns SecurityGroupArns>.
--
-- 'subnetArns', 'createAgent_subnetArns' - The Amazon Resource Names (ARNs) of the subnets in which DataSync will
-- create elastic network interfaces for each data transfer task. The agent
-- that runs a task must be private. When you start a task that is
-- associated with an agent created in a VPC, or one that has access to an
-- IP address in a VPC, then the task is also private. In this case,
-- DataSync creates four network interfaces for each task in your subnet.
-- For a data transfer to work, the agent must be able to route to all
-- these four network interfaces.
--
-- 'agentName', 'createAgent_agentName' - The name you configured for your agent. This value is a text reference
-- that is used to identify the agent in the console.
--
-- 'vpcEndpointId', 'createAgent_vpcEndpointId' - The ID of the VPC (virtual private cloud) endpoint that the agent has
-- access to. This is the client-side VPC endpoint, also called a
-- PrivateLink. If you don\'t have a PrivateLink VPC endpoint, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html#create-endpoint-service Creating a VPC Endpoint Service Configuration>
-- in the Amazon VPC User Guide.
--
-- VPC endpoint ID looks like this: @vpce-01234d5aff67890e1@.
--
-- 'tags', 'createAgent_tags' - The key-value pair that represents the tag that you want to associate
-- with the agent. The value can be an empty string. This value helps you
-- manage, filter, and search for your agents.
--
-- Valid characters for key and value are letters, spaces, and numbers
-- representable in UTF-8 format, and the following special characters: + -
-- = . _ : \/ \@.
--
-- 'activationKey', 'createAgent_activationKey' - Your agent activation key. You can get the activation key either by
-- sending an HTTP GET request with redirects that enable you to get the
-- agent IP address (port 80). Alternatively, you can get it from the
-- DataSync console.
--
-- The redirect URL returned in the response provides you the activation
-- key for your agent in the query string parameter @activationKey@. It
-- might also include other activation-related parameters; however, these
-- are merely defaults. The arguments you pass to this API call determine
-- the actual configuration of your agent.
--
-- For more information, see Activating an Agent in the /DataSync User
-- Guide./
newCreateAgent ::
  -- | 'activationKey'
  Prelude.Text ->
  CreateAgent
newCreateAgent :: Text -> CreateAgent
newCreateAgent Text
pActivationKey_ =
  CreateAgent' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text)
-> Maybe Text
-> Maybe Text
-> Maybe [TagListEntry]
-> Text
-> CreateAgent
CreateAgent'
    { $sel:securityGroupArns:CreateAgent' :: Maybe (NonEmpty Text)
securityGroupArns = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:subnetArns:CreateAgent' :: Maybe (NonEmpty Text)
subnetArns = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:agentName:CreateAgent' :: Maybe Text
agentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcEndpointId:CreateAgent' :: Maybe Text
vpcEndpointId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateAgent' :: Maybe [TagListEntry]
tags = Maybe [TagListEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:activationKey:CreateAgent' :: Text
activationKey = Text
pActivationKey_
    }

-- | The ARNs of the security groups used to protect your data transfer task
-- subnets. See
-- <https://docs.aws.amazon.com/datasync/latest/userguide/API_Ec2Config.html#DataSync-Type-Ec2Config-SecurityGroupArns SecurityGroupArns>.
createAgent_securityGroupArns :: Lens.Lens' CreateAgent (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
createAgent_securityGroupArns :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateAgent -> f CreateAgent
createAgent_securityGroupArns = (CreateAgent -> Maybe (NonEmpty Text))
-> (CreateAgent -> Maybe (NonEmpty Text) -> CreateAgent)
-> Lens
     CreateAgent
     CreateAgent
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Maybe (NonEmpty Text)
securityGroupArns :: Maybe (NonEmpty Text)
$sel:securityGroupArns:CreateAgent' :: CreateAgent -> Maybe (NonEmpty Text)
securityGroupArns} -> Maybe (NonEmpty Text)
securityGroupArns) (\s :: CreateAgent
s@CreateAgent' {} Maybe (NonEmpty Text)
a -> CreateAgent
s {$sel:securityGroupArns:CreateAgent' :: Maybe (NonEmpty Text)
securityGroupArns = Maybe (NonEmpty Text)
a} :: CreateAgent) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> CreateAgent -> f CreateAgent)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateAgent
-> f CreateAgent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Names (ARNs) of the subnets in which DataSync will
-- create elastic network interfaces for each data transfer task. The agent
-- that runs a task must be private. When you start a task that is
-- associated with an agent created in a VPC, or one that has access to an
-- IP address in a VPC, then the task is also private. In this case,
-- DataSync creates four network interfaces for each task in your subnet.
-- For a data transfer to work, the agent must be able to route to all
-- these four network interfaces.
createAgent_subnetArns :: Lens.Lens' CreateAgent (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
createAgent_subnetArns :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateAgent -> f CreateAgent
createAgent_subnetArns = (CreateAgent -> Maybe (NonEmpty Text))
-> (CreateAgent -> Maybe (NonEmpty Text) -> CreateAgent)
-> Lens
     CreateAgent
     CreateAgent
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Maybe (NonEmpty Text)
subnetArns :: Maybe (NonEmpty Text)
$sel:subnetArns:CreateAgent' :: CreateAgent -> Maybe (NonEmpty Text)
subnetArns} -> Maybe (NonEmpty Text)
subnetArns) (\s :: CreateAgent
s@CreateAgent' {} Maybe (NonEmpty Text)
a -> CreateAgent
s {$sel:subnetArns:CreateAgent' :: Maybe (NonEmpty Text)
subnetArns = Maybe (NonEmpty Text)
a} :: CreateAgent) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> CreateAgent -> f CreateAgent)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> CreateAgent
-> f CreateAgent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name you configured for your agent. This value is a text reference
-- that is used to identify the agent in the console.
createAgent_agentName :: Lens.Lens' CreateAgent (Prelude.Maybe Prelude.Text)
createAgent_agentName :: (Maybe Text -> f (Maybe Text)) -> CreateAgent -> f CreateAgent
createAgent_agentName = (CreateAgent -> Maybe Text)
-> (CreateAgent -> Maybe Text -> CreateAgent)
-> Lens CreateAgent CreateAgent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Maybe Text
agentName :: Maybe Text
$sel:agentName:CreateAgent' :: CreateAgent -> Maybe Text
agentName} -> Maybe Text
agentName) (\s :: CreateAgent
s@CreateAgent' {} Maybe Text
a -> CreateAgent
s {$sel:agentName:CreateAgent' :: Maybe Text
agentName = Maybe Text
a} :: CreateAgent)

-- | The ID of the VPC (virtual private cloud) endpoint that the agent has
-- access to. This is the client-side VPC endpoint, also called a
-- PrivateLink. If you don\'t have a PrivateLink VPC endpoint, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html#create-endpoint-service Creating a VPC Endpoint Service Configuration>
-- in the Amazon VPC User Guide.
--
-- VPC endpoint ID looks like this: @vpce-01234d5aff67890e1@.
createAgent_vpcEndpointId :: Lens.Lens' CreateAgent (Prelude.Maybe Prelude.Text)
createAgent_vpcEndpointId :: (Maybe Text -> f (Maybe Text)) -> CreateAgent -> f CreateAgent
createAgent_vpcEndpointId = (CreateAgent -> Maybe Text)
-> (CreateAgent -> Maybe Text -> CreateAgent)
-> Lens CreateAgent CreateAgent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Maybe Text
vpcEndpointId :: Maybe Text
$sel:vpcEndpointId:CreateAgent' :: CreateAgent -> Maybe Text
vpcEndpointId} -> Maybe Text
vpcEndpointId) (\s :: CreateAgent
s@CreateAgent' {} Maybe Text
a -> CreateAgent
s {$sel:vpcEndpointId:CreateAgent' :: Maybe Text
vpcEndpointId = Maybe Text
a} :: CreateAgent)

-- | The key-value pair that represents the tag that you want to associate
-- with the agent. The value can be an empty string. This value helps you
-- manage, filter, and search for your agents.
--
-- Valid characters for key and value are letters, spaces, and numbers
-- representable in UTF-8 format, and the following special characters: + -
-- = . _ : \/ \@.
createAgent_tags :: Lens.Lens' CreateAgent (Prelude.Maybe [TagListEntry])
createAgent_tags :: (Maybe [TagListEntry] -> f (Maybe [TagListEntry]))
-> CreateAgent -> f CreateAgent
createAgent_tags = (CreateAgent -> Maybe [TagListEntry])
-> (CreateAgent -> Maybe [TagListEntry] -> CreateAgent)
-> Lens
     CreateAgent
     CreateAgent
     (Maybe [TagListEntry])
     (Maybe [TagListEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Maybe [TagListEntry]
tags :: Maybe [TagListEntry]
$sel:tags:CreateAgent' :: CreateAgent -> Maybe [TagListEntry]
tags} -> Maybe [TagListEntry]
tags) (\s :: CreateAgent
s@CreateAgent' {} Maybe [TagListEntry]
a -> CreateAgent
s {$sel:tags:CreateAgent' :: Maybe [TagListEntry]
tags = Maybe [TagListEntry]
a} :: CreateAgent) ((Maybe [TagListEntry] -> f (Maybe [TagListEntry]))
 -> CreateAgent -> f CreateAgent)
-> ((Maybe [TagListEntry] -> f (Maybe [TagListEntry]))
    -> Maybe [TagListEntry] -> f (Maybe [TagListEntry]))
-> (Maybe [TagListEntry] -> f (Maybe [TagListEntry]))
-> CreateAgent
-> f CreateAgent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TagListEntry] [TagListEntry] [TagListEntry] [TagListEntry]
-> Iso
     (Maybe [TagListEntry])
     (Maybe [TagListEntry])
     (Maybe [TagListEntry])
     (Maybe [TagListEntry])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [TagListEntry] [TagListEntry] [TagListEntry] [TagListEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Your agent activation key. You can get the activation key either by
-- sending an HTTP GET request with redirects that enable you to get the
-- agent IP address (port 80). Alternatively, you can get it from the
-- DataSync console.
--
-- The redirect URL returned in the response provides you the activation
-- key for your agent in the query string parameter @activationKey@. It
-- might also include other activation-related parameters; however, these
-- are merely defaults. The arguments you pass to this API call determine
-- the actual configuration of your agent.
--
-- For more information, see Activating an Agent in the /DataSync User
-- Guide./
createAgent_activationKey :: Lens.Lens' CreateAgent Prelude.Text
createAgent_activationKey :: (Text -> f Text) -> CreateAgent -> f CreateAgent
createAgent_activationKey = (CreateAgent -> Text)
-> (CreateAgent -> Text -> CreateAgent)
-> Lens CreateAgent CreateAgent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgent' {Text
activationKey :: Text
$sel:activationKey:CreateAgent' :: CreateAgent -> Text
activationKey} -> Text
activationKey) (\s :: CreateAgent
s@CreateAgent' {} Text
a -> CreateAgent
s {$sel:activationKey:CreateAgent' :: Text
activationKey = Text
a} :: CreateAgent)

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

instance Prelude.NFData CreateAgent

instance Core.ToHeaders CreateAgent where
  toHeaders :: CreateAgent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAgent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"FmrsService.CreateAgent" :: Prelude.ByteString),
            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 CreateAgent where
  toJSON :: CreateAgent -> Value
toJSON CreateAgent' {Maybe [TagListEntry]
Maybe (NonEmpty Text)
Maybe Text
Text
activationKey :: Text
tags :: Maybe [TagListEntry]
vpcEndpointId :: Maybe Text
agentName :: Maybe Text
subnetArns :: Maybe (NonEmpty Text)
securityGroupArns :: Maybe (NonEmpty Text)
$sel:activationKey:CreateAgent' :: CreateAgent -> Text
$sel:tags:CreateAgent' :: CreateAgent -> Maybe [TagListEntry]
$sel:vpcEndpointId:CreateAgent' :: CreateAgent -> Maybe Text
$sel:agentName:CreateAgent' :: CreateAgent -> Maybe Text
$sel:subnetArns:CreateAgent' :: CreateAgent -> Maybe (NonEmpty Text)
$sel:securityGroupArns:CreateAgent' :: CreateAgent -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SecurityGroupArns" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
securityGroupArns,
            (Text
"SubnetArns" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
subnetArns,
            (Text
"AgentName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
agentName,
            (Text
"VpcEndpointId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vpcEndpointId,
            (Text
"Tags" Text -> [TagListEntry] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([TagListEntry] -> Pair) -> Maybe [TagListEntry] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagListEntry]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ActivationKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
activationKey)
          ]
      )

instance Core.ToPath CreateAgent where
  toPath :: CreateAgent -> ByteString
toPath = ByteString -> CreateAgent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | CreateAgentResponse
--
-- /See:/ 'newCreateAgentResponse' smart constructor.
data CreateAgentResponse = CreateAgentResponse'
  { -- | The Amazon Resource Name (ARN) of the agent. Use the @ListAgents@
    -- operation to return a list of agents for your account and Amazon Web
    -- Services Region.
    CreateAgentResponse -> Maybe Text
agentArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateAgentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateAgentResponse -> CreateAgentResponse -> Bool
(CreateAgentResponse -> CreateAgentResponse -> Bool)
-> (CreateAgentResponse -> CreateAgentResponse -> Bool)
-> Eq CreateAgentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAgentResponse -> CreateAgentResponse -> Bool
$c/= :: CreateAgentResponse -> CreateAgentResponse -> Bool
== :: CreateAgentResponse -> CreateAgentResponse -> Bool
$c== :: CreateAgentResponse -> CreateAgentResponse -> Bool
Prelude.Eq, ReadPrec [CreateAgentResponse]
ReadPrec CreateAgentResponse
Int -> ReadS CreateAgentResponse
ReadS [CreateAgentResponse]
(Int -> ReadS CreateAgentResponse)
-> ReadS [CreateAgentResponse]
-> ReadPrec CreateAgentResponse
-> ReadPrec [CreateAgentResponse]
-> Read CreateAgentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAgentResponse]
$creadListPrec :: ReadPrec [CreateAgentResponse]
readPrec :: ReadPrec CreateAgentResponse
$creadPrec :: ReadPrec CreateAgentResponse
readList :: ReadS [CreateAgentResponse]
$creadList :: ReadS [CreateAgentResponse]
readsPrec :: Int -> ReadS CreateAgentResponse
$creadsPrec :: Int -> ReadS CreateAgentResponse
Prelude.Read, Int -> CreateAgentResponse -> ShowS
[CreateAgentResponse] -> ShowS
CreateAgentResponse -> String
(Int -> CreateAgentResponse -> ShowS)
-> (CreateAgentResponse -> String)
-> ([CreateAgentResponse] -> ShowS)
-> Show CreateAgentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAgentResponse] -> ShowS
$cshowList :: [CreateAgentResponse] -> ShowS
show :: CreateAgentResponse -> String
$cshow :: CreateAgentResponse -> String
showsPrec :: Int -> CreateAgentResponse -> ShowS
$cshowsPrec :: Int -> CreateAgentResponse -> ShowS
Prelude.Show, (forall x. CreateAgentResponse -> Rep CreateAgentResponse x)
-> (forall x. Rep CreateAgentResponse x -> CreateAgentResponse)
-> Generic CreateAgentResponse
forall x. Rep CreateAgentResponse x -> CreateAgentResponse
forall x. CreateAgentResponse -> Rep CreateAgentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAgentResponse x -> CreateAgentResponse
$cfrom :: forall x. CreateAgentResponse -> Rep CreateAgentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateAgentResponse' 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:
--
-- 'agentArn', 'createAgentResponse_agentArn' - The Amazon Resource Name (ARN) of the agent. Use the @ListAgents@
-- operation to return a list of agents for your account and Amazon Web
-- Services Region.
--
-- 'httpStatus', 'createAgentResponse_httpStatus' - The response's http status code.
newCreateAgentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAgentResponse
newCreateAgentResponse :: Int -> CreateAgentResponse
newCreateAgentResponse Int
pHttpStatus_ =
  CreateAgentResponse' :: Maybe Text -> Int -> CreateAgentResponse
CreateAgentResponse'
    { $sel:agentArn:CreateAgentResponse' :: Maybe Text
agentArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAgentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the agent. Use the @ListAgents@
-- operation to return a list of agents for your account and Amazon Web
-- Services Region.
createAgentResponse_agentArn :: Lens.Lens' CreateAgentResponse (Prelude.Maybe Prelude.Text)
createAgentResponse_agentArn :: (Maybe Text -> f (Maybe Text))
-> CreateAgentResponse -> f CreateAgentResponse
createAgentResponse_agentArn = (CreateAgentResponse -> Maybe Text)
-> (CreateAgentResponse -> Maybe Text -> CreateAgentResponse)
-> Lens
     CreateAgentResponse CreateAgentResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAgentResponse' {Maybe Text
agentArn :: Maybe Text
$sel:agentArn:CreateAgentResponse' :: CreateAgentResponse -> Maybe Text
agentArn} -> Maybe Text
agentArn) (\s :: CreateAgentResponse
s@CreateAgentResponse' {} Maybe Text
a -> CreateAgentResponse
s {$sel:agentArn:CreateAgentResponse' :: Maybe Text
agentArn = Maybe Text
a} :: CreateAgentResponse)

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

instance Prelude.NFData CreateAgentResponse