{-# 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.Transfer.DescribeAccess
-- 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)
--
-- Describes the access that is assigned to the specific file transfer
-- protocol-enabled server, as identified by its @ServerId@ property and
-- its @ExternalID@.
--
-- The response from this call returns the properties of the access that is
-- associated with the @ServerId@ value that was specified.
module Amazonka.Transfer.DescribeAccess
  ( -- * Creating a Request
    DescribeAccess (..),
    newDescribeAccess,

    -- * Request Lenses
    describeAccess_serverId,
    describeAccess_externalId,

    -- * Destructuring the Response
    DescribeAccessResponse (..),
    newDescribeAccessResponse,

    -- * Response Lenses
    describeAccessResponse_httpStatus,
    describeAccessResponse_serverId,
    describeAccessResponse_access,
  )
where

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

-- | /See:/ 'newDescribeAccess' smart constructor.
data DescribeAccess = DescribeAccess'
  { -- | A system-assigned unique identifier for a server that has this access
    -- assigned.
    DescribeAccess -> Text
serverId :: Prelude.Text,
    -- | A unique identifier that is required to identify specific groups within
    -- your directory. The users of the group that you associate have access to
    -- your Amazon S3 or Amazon EFS resources over the enabled protocols using
    -- Amazon Web Services Transfer Family. If you know the group name, you can
    -- view the SID values by running the following command using Windows
    -- PowerShell.
    --
    -- @Get-ADGroup -Filter {samAccountName -like \"YourGroupName*\"} -Properties * | Select SamAccountName,ObjectSid@
    --
    -- In that command, replace /YourGroupName/ with the name of your Active
    -- Directory group.
    --
    -- The regex used to validate this parameter is a string of characters
    -- consisting of uppercase and lowercase alphanumeric characters with no
    -- spaces. You can also include underscores or any of the following
    -- characters: =,.\@:\/-
    DescribeAccess -> Text
externalId :: Prelude.Text
  }
  deriving (DescribeAccess -> DescribeAccess -> Bool
(DescribeAccess -> DescribeAccess -> Bool)
-> (DescribeAccess -> DescribeAccess -> Bool) -> Eq DescribeAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccess -> DescribeAccess -> Bool
$c/= :: DescribeAccess -> DescribeAccess -> Bool
== :: DescribeAccess -> DescribeAccess -> Bool
$c== :: DescribeAccess -> DescribeAccess -> Bool
Prelude.Eq, ReadPrec [DescribeAccess]
ReadPrec DescribeAccess
Int -> ReadS DescribeAccess
ReadS [DescribeAccess]
(Int -> ReadS DescribeAccess)
-> ReadS [DescribeAccess]
-> ReadPrec DescribeAccess
-> ReadPrec [DescribeAccess]
-> Read DescribeAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccess]
$creadListPrec :: ReadPrec [DescribeAccess]
readPrec :: ReadPrec DescribeAccess
$creadPrec :: ReadPrec DescribeAccess
readList :: ReadS [DescribeAccess]
$creadList :: ReadS [DescribeAccess]
readsPrec :: Int -> ReadS DescribeAccess
$creadsPrec :: Int -> ReadS DescribeAccess
Prelude.Read, Int -> DescribeAccess -> ShowS
[DescribeAccess] -> ShowS
DescribeAccess -> String
(Int -> DescribeAccess -> ShowS)
-> (DescribeAccess -> String)
-> ([DescribeAccess] -> ShowS)
-> Show DescribeAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccess] -> ShowS
$cshowList :: [DescribeAccess] -> ShowS
show :: DescribeAccess -> String
$cshow :: DescribeAccess -> String
showsPrec :: Int -> DescribeAccess -> ShowS
$cshowsPrec :: Int -> DescribeAccess -> ShowS
Prelude.Show, (forall x. DescribeAccess -> Rep DescribeAccess x)
-> (forall x. Rep DescribeAccess x -> DescribeAccess)
-> Generic DescribeAccess
forall x. Rep DescribeAccess x -> DescribeAccess
forall x. DescribeAccess -> Rep DescribeAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAccess x -> DescribeAccess
$cfrom :: forall x. DescribeAccess -> Rep DescribeAccess x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccess' 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:
--
-- 'serverId', 'describeAccess_serverId' - A system-assigned unique identifier for a server that has this access
-- assigned.
--
-- 'externalId', 'describeAccess_externalId' - A unique identifier that is required to identify specific groups within
-- your directory. The users of the group that you associate have access to
-- your Amazon S3 or Amazon EFS resources over the enabled protocols using
-- Amazon Web Services Transfer Family. If you know the group name, you can
-- view the SID values by running the following command using Windows
-- PowerShell.
--
-- @Get-ADGroup -Filter {samAccountName -like \"YourGroupName*\"} -Properties * | Select SamAccountName,ObjectSid@
--
-- In that command, replace /YourGroupName/ with the name of your Active
-- Directory group.
--
-- The regex used to validate this parameter is a string of characters
-- consisting of uppercase and lowercase alphanumeric characters with no
-- spaces. You can also include underscores or any of the following
-- characters: =,.\@:\/-
newDescribeAccess ::
  -- | 'serverId'
  Prelude.Text ->
  -- | 'externalId'
  Prelude.Text ->
  DescribeAccess
newDescribeAccess :: Text -> Text -> DescribeAccess
newDescribeAccess Text
pServerId_ Text
pExternalId_ =
  DescribeAccess' :: Text -> Text -> DescribeAccess
DescribeAccess'
    { $sel:serverId:DescribeAccess' :: Text
serverId = Text
pServerId_,
      $sel:externalId:DescribeAccess' :: Text
externalId = Text
pExternalId_
    }

-- | A system-assigned unique identifier for a server that has this access
-- assigned.
describeAccess_serverId :: Lens.Lens' DescribeAccess Prelude.Text
describeAccess_serverId :: (Text -> f Text) -> DescribeAccess -> f DescribeAccess
describeAccess_serverId = (DescribeAccess -> Text)
-> (DescribeAccess -> Text -> DescribeAccess)
-> Lens DescribeAccess DescribeAccess Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccess' {Text
serverId :: Text
$sel:serverId:DescribeAccess' :: DescribeAccess -> Text
serverId} -> Text
serverId) (\s :: DescribeAccess
s@DescribeAccess' {} Text
a -> DescribeAccess
s {$sel:serverId:DescribeAccess' :: Text
serverId = Text
a} :: DescribeAccess)

-- | A unique identifier that is required to identify specific groups within
-- your directory. The users of the group that you associate have access to
-- your Amazon S3 or Amazon EFS resources over the enabled protocols using
-- Amazon Web Services Transfer Family. If you know the group name, you can
-- view the SID values by running the following command using Windows
-- PowerShell.
--
-- @Get-ADGroup -Filter {samAccountName -like \"YourGroupName*\"} -Properties * | Select SamAccountName,ObjectSid@
--
-- In that command, replace /YourGroupName/ with the name of your Active
-- Directory group.
--
-- The regex used to validate this parameter is a string of characters
-- consisting of uppercase and lowercase alphanumeric characters with no
-- spaces. You can also include underscores or any of the following
-- characters: =,.\@:\/-
describeAccess_externalId :: Lens.Lens' DescribeAccess Prelude.Text
describeAccess_externalId :: (Text -> f Text) -> DescribeAccess -> f DescribeAccess
describeAccess_externalId = (DescribeAccess -> Text)
-> (DescribeAccess -> Text -> DescribeAccess)
-> Lens DescribeAccess DescribeAccess Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccess' {Text
externalId :: Text
$sel:externalId:DescribeAccess' :: DescribeAccess -> Text
externalId} -> Text
externalId) (\s :: DescribeAccess
s@DescribeAccess' {} Text
a -> DescribeAccess
s {$sel:externalId:DescribeAccess' :: Text
externalId = Text
a} :: DescribeAccess)

instance Core.AWSRequest DescribeAccess where
  type
    AWSResponse DescribeAccess =
      DescribeAccessResponse
  request :: DescribeAccess -> Request DescribeAccess
request = Service -> DescribeAccess -> Request DescribeAccess
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAccess)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeAccess))
-> Logger
-> Service
-> Proxy DescribeAccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAccess)))
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 -> Text -> DescribedAccess -> DescribeAccessResponse
DescribeAccessResponse'
            (Int -> Text -> DescribedAccess -> DescribeAccessResponse)
-> Either String Int
-> Either
     String (Text -> DescribedAccess -> DescribeAccessResponse)
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 (Text -> DescribedAccess -> DescribeAccessResponse)
-> Either String Text
-> Either String (DescribedAccess -> DescribeAccessResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ServerId")
            Either String (DescribedAccess -> DescribeAccessResponse)
-> Either String DescribedAccess
-> Either String DescribeAccessResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String DescribedAccess
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Access")
      )

instance Prelude.Hashable DescribeAccess

instance Prelude.NFData DescribeAccess

instance Core.ToHeaders DescribeAccess where
  toHeaders :: DescribeAccess -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeAccess -> 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
"TransferService.DescribeAccess" ::
                          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 DescribeAccess where
  toJSON :: DescribeAccess -> Value
toJSON DescribeAccess' {Text
externalId :: Text
serverId :: Text
$sel:externalId:DescribeAccess' :: DescribeAccess -> Text
$sel:serverId:DescribeAccess' :: DescribeAccess -> 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
"ServerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ExternalId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
externalId)
          ]
      )

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

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

-- | /See:/ 'newDescribeAccessResponse' smart constructor.
data DescribeAccessResponse = DescribeAccessResponse'
  { -- | The response's http status code.
    DescribeAccessResponse -> Int
httpStatus :: Prelude.Int,
    -- | A system-assigned unique identifier for a server that has this access
    -- assigned.
    DescribeAccessResponse -> Text
serverId :: Prelude.Text,
    -- | The external ID of the server that the access is attached to.
    DescribeAccessResponse -> DescribedAccess
access :: DescribedAccess
  }
  deriving (DescribeAccessResponse -> DescribeAccessResponse -> Bool
(DescribeAccessResponse -> DescribeAccessResponse -> Bool)
-> (DescribeAccessResponse -> DescribeAccessResponse -> Bool)
-> Eq DescribeAccessResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccessResponse -> DescribeAccessResponse -> Bool
$c/= :: DescribeAccessResponse -> DescribeAccessResponse -> Bool
== :: DescribeAccessResponse -> DescribeAccessResponse -> Bool
$c== :: DescribeAccessResponse -> DescribeAccessResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAccessResponse]
ReadPrec DescribeAccessResponse
Int -> ReadS DescribeAccessResponse
ReadS [DescribeAccessResponse]
(Int -> ReadS DescribeAccessResponse)
-> ReadS [DescribeAccessResponse]
-> ReadPrec DescribeAccessResponse
-> ReadPrec [DescribeAccessResponse]
-> Read DescribeAccessResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccessResponse]
$creadListPrec :: ReadPrec [DescribeAccessResponse]
readPrec :: ReadPrec DescribeAccessResponse
$creadPrec :: ReadPrec DescribeAccessResponse
readList :: ReadS [DescribeAccessResponse]
$creadList :: ReadS [DescribeAccessResponse]
readsPrec :: Int -> ReadS DescribeAccessResponse
$creadsPrec :: Int -> ReadS DescribeAccessResponse
Prelude.Read, Int -> DescribeAccessResponse -> ShowS
[DescribeAccessResponse] -> ShowS
DescribeAccessResponse -> String
(Int -> DescribeAccessResponse -> ShowS)
-> (DescribeAccessResponse -> String)
-> ([DescribeAccessResponse] -> ShowS)
-> Show DescribeAccessResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccessResponse] -> ShowS
$cshowList :: [DescribeAccessResponse] -> ShowS
show :: DescribeAccessResponse -> String
$cshow :: DescribeAccessResponse -> String
showsPrec :: Int -> DescribeAccessResponse -> ShowS
$cshowsPrec :: Int -> DescribeAccessResponse -> ShowS
Prelude.Show, (forall x. DescribeAccessResponse -> Rep DescribeAccessResponse x)
-> (forall x.
    Rep DescribeAccessResponse x -> DescribeAccessResponse)
-> Generic DescribeAccessResponse
forall x. Rep DescribeAccessResponse x -> DescribeAccessResponse
forall x. DescribeAccessResponse -> Rep DescribeAccessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAccessResponse x -> DescribeAccessResponse
$cfrom :: forall x. DescribeAccessResponse -> Rep DescribeAccessResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccessResponse' 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', 'describeAccessResponse_httpStatus' - The response's http status code.
--
-- 'serverId', 'describeAccessResponse_serverId' - A system-assigned unique identifier for a server that has this access
-- assigned.
--
-- 'access', 'describeAccessResponse_access' - The external ID of the server that the access is attached to.
newDescribeAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'serverId'
  Prelude.Text ->
  -- | 'access'
  DescribedAccess ->
  DescribeAccessResponse
newDescribeAccessResponse :: Int -> Text -> DescribedAccess -> DescribeAccessResponse
newDescribeAccessResponse
  Int
pHttpStatus_
  Text
pServerId_
  DescribedAccess
pAccess_ =
    DescribeAccessResponse' :: Int -> Text -> DescribedAccess -> DescribeAccessResponse
DescribeAccessResponse'
      { $sel:httpStatus:DescribeAccessResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:serverId:DescribeAccessResponse' :: Text
serverId = Text
pServerId_,
        $sel:access:DescribeAccessResponse' :: DescribedAccess
access = DescribedAccess
pAccess_
      }

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

-- | A system-assigned unique identifier for a server that has this access
-- assigned.
describeAccessResponse_serverId :: Lens.Lens' DescribeAccessResponse Prelude.Text
describeAccessResponse_serverId :: (Text -> f Text)
-> DescribeAccessResponse -> f DescribeAccessResponse
describeAccessResponse_serverId = (DescribeAccessResponse -> Text)
-> (DescribeAccessResponse -> Text -> DescribeAccessResponse)
-> Lens DescribeAccessResponse DescribeAccessResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccessResponse' {Text
serverId :: Text
$sel:serverId:DescribeAccessResponse' :: DescribeAccessResponse -> Text
serverId} -> Text
serverId) (\s :: DescribeAccessResponse
s@DescribeAccessResponse' {} Text
a -> DescribeAccessResponse
s {$sel:serverId:DescribeAccessResponse' :: Text
serverId = Text
a} :: DescribeAccessResponse)

-- | The external ID of the server that the access is attached to.
describeAccessResponse_access :: Lens.Lens' DescribeAccessResponse DescribedAccess
describeAccessResponse_access :: (DescribedAccess -> f DescribedAccess)
-> DescribeAccessResponse -> f DescribeAccessResponse
describeAccessResponse_access = (DescribeAccessResponse -> DescribedAccess)
-> (DescribeAccessResponse
    -> DescribedAccess -> DescribeAccessResponse)
-> Lens
     DescribeAccessResponse
     DescribeAccessResponse
     DescribedAccess
     DescribedAccess
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccessResponse' {DescribedAccess
access :: DescribedAccess
$sel:access:DescribeAccessResponse' :: DescribeAccessResponse -> DescribedAccess
access} -> DescribedAccess
access) (\s :: DescribeAccessResponse
s@DescribeAccessResponse' {} DescribedAccess
a -> DescribeAccessResponse
s {$sel:access:DescribeAccessResponse' :: DescribedAccess
access = DescribedAccess
a} :: DescribeAccessResponse)

instance Prelude.NFData DescribeAccessResponse