{-# 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.SageMaker.DescribeWorkforce
-- 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)
--
-- Lists private workforce information, including workforce name, Amazon
-- Resource Name (ARN), and, if applicable, allowed IP address ranges
-- (<https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html CIDRs>).
-- Allowable IP address ranges are the IP addresses that workers can use to
-- access tasks.
--
-- This operation applies only to private workforces.
module Amazonka.SageMaker.DescribeWorkforce
  ( -- * Creating a Request
    DescribeWorkforce (..),
    newDescribeWorkforce,

    -- * Request Lenses
    describeWorkforce_workforceName,

    -- * Destructuring the Response
    DescribeWorkforceResponse (..),
    newDescribeWorkforceResponse,

    -- * Response Lenses
    describeWorkforceResponse_httpStatus,
    describeWorkforceResponse_workforce,
  )
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.SageMaker.Types

-- | /See:/ 'newDescribeWorkforce' smart constructor.
data DescribeWorkforce = DescribeWorkforce'
  { -- | The name of the private workforce whose access you want to restrict.
    -- @WorkforceName@ is automatically set to @default@ when a workforce is
    -- created and cannot be modified.
    DescribeWorkforce -> Text
workforceName :: Prelude.Text
  }
  deriving (DescribeWorkforce -> DescribeWorkforce -> Bool
(DescribeWorkforce -> DescribeWorkforce -> Bool)
-> (DescribeWorkforce -> DescribeWorkforce -> Bool)
-> Eq DescribeWorkforce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeWorkforce -> DescribeWorkforce -> Bool
$c/= :: DescribeWorkforce -> DescribeWorkforce -> Bool
== :: DescribeWorkforce -> DescribeWorkforce -> Bool
$c== :: DescribeWorkforce -> DescribeWorkforce -> Bool
Prelude.Eq, ReadPrec [DescribeWorkforce]
ReadPrec DescribeWorkforce
Int -> ReadS DescribeWorkforce
ReadS [DescribeWorkforce]
(Int -> ReadS DescribeWorkforce)
-> ReadS [DescribeWorkforce]
-> ReadPrec DescribeWorkforce
-> ReadPrec [DescribeWorkforce]
-> Read DescribeWorkforce
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeWorkforce]
$creadListPrec :: ReadPrec [DescribeWorkforce]
readPrec :: ReadPrec DescribeWorkforce
$creadPrec :: ReadPrec DescribeWorkforce
readList :: ReadS [DescribeWorkforce]
$creadList :: ReadS [DescribeWorkforce]
readsPrec :: Int -> ReadS DescribeWorkforce
$creadsPrec :: Int -> ReadS DescribeWorkforce
Prelude.Read, Int -> DescribeWorkforce -> ShowS
[DescribeWorkforce] -> ShowS
DescribeWorkforce -> String
(Int -> DescribeWorkforce -> ShowS)
-> (DescribeWorkforce -> String)
-> ([DescribeWorkforce] -> ShowS)
-> Show DescribeWorkforce
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeWorkforce] -> ShowS
$cshowList :: [DescribeWorkforce] -> ShowS
show :: DescribeWorkforce -> String
$cshow :: DescribeWorkforce -> String
showsPrec :: Int -> DescribeWorkforce -> ShowS
$cshowsPrec :: Int -> DescribeWorkforce -> ShowS
Prelude.Show, (forall x. DescribeWorkforce -> Rep DescribeWorkforce x)
-> (forall x. Rep DescribeWorkforce x -> DescribeWorkforce)
-> Generic DescribeWorkforce
forall x. Rep DescribeWorkforce x -> DescribeWorkforce
forall x. DescribeWorkforce -> Rep DescribeWorkforce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeWorkforce x -> DescribeWorkforce
$cfrom :: forall x. DescribeWorkforce -> Rep DescribeWorkforce x
Prelude.Generic)

-- |
-- Create a value of 'DescribeWorkforce' 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:
--
-- 'workforceName', 'describeWorkforce_workforceName' - The name of the private workforce whose access you want to restrict.
-- @WorkforceName@ is automatically set to @default@ when a workforce is
-- created and cannot be modified.
newDescribeWorkforce ::
  -- | 'workforceName'
  Prelude.Text ->
  DescribeWorkforce
newDescribeWorkforce :: Text -> DescribeWorkforce
newDescribeWorkforce Text
pWorkforceName_ =
  DescribeWorkforce' :: Text -> DescribeWorkforce
DescribeWorkforce' {$sel:workforceName:DescribeWorkforce' :: Text
workforceName = Text
pWorkforceName_}

-- | The name of the private workforce whose access you want to restrict.
-- @WorkforceName@ is automatically set to @default@ when a workforce is
-- created and cannot be modified.
describeWorkforce_workforceName :: Lens.Lens' DescribeWorkforce Prelude.Text
describeWorkforce_workforceName :: (Text -> f Text) -> DescribeWorkforce -> f DescribeWorkforce
describeWorkforce_workforceName = (DescribeWorkforce -> Text)
-> (DescribeWorkforce -> Text -> DescribeWorkforce)
-> Lens DescribeWorkforce DescribeWorkforce Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkforce' {Text
workforceName :: Text
$sel:workforceName:DescribeWorkforce' :: DescribeWorkforce -> Text
workforceName} -> Text
workforceName) (\s :: DescribeWorkforce
s@DescribeWorkforce' {} Text
a -> DescribeWorkforce
s {$sel:workforceName:DescribeWorkforce' :: Text
workforceName = Text
a} :: DescribeWorkforce)

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

instance Prelude.Hashable DescribeWorkforce

instance Prelude.NFData DescribeWorkforce

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

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

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

-- | /See:/ 'newDescribeWorkforceResponse' smart constructor.
data DescribeWorkforceResponse = DescribeWorkforceResponse'
  { -- | The response's http status code.
    DescribeWorkforceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A single private workforce, which is automatically created when you
    -- create your first private work team. You can create one private work
    -- force in each Amazon Web Services Region. By default, any
    -- workforce-related API operation used in a specific region will apply to
    -- the workforce created in that region. To learn how to create a private
    -- workforce, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private.html Create a Private Workforce>.
    DescribeWorkforceResponse -> Workforce
workforce :: Workforce
  }
  deriving (DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool
(DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool)
-> (DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool)
-> Eq DescribeWorkforceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool
$c/= :: DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool
== :: DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool
$c== :: DescribeWorkforceResponse -> DescribeWorkforceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeWorkforceResponse]
ReadPrec DescribeWorkforceResponse
Int -> ReadS DescribeWorkforceResponse
ReadS [DescribeWorkforceResponse]
(Int -> ReadS DescribeWorkforceResponse)
-> ReadS [DescribeWorkforceResponse]
-> ReadPrec DescribeWorkforceResponse
-> ReadPrec [DescribeWorkforceResponse]
-> Read DescribeWorkforceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeWorkforceResponse]
$creadListPrec :: ReadPrec [DescribeWorkforceResponse]
readPrec :: ReadPrec DescribeWorkforceResponse
$creadPrec :: ReadPrec DescribeWorkforceResponse
readList :: ReadS [DescribeWorkforceResponse]
$creadList :: ReadS [DescribeWorkforceResponse]
readsPrec :: Int -> ReadS DescribeWorkforceResponse
$creadsPrec :: Int -> ReadS DescribeWorkforceResponse
Prelude.Read, Int -> DescribeWorkforceResponse -> ShowS
[DescribeWorkforceResponse] -> ShowS
DescribeWorkforceResponse -> String
(Int -> DescribeWorkforceResponse -> ShowS)
-> (DescribeWorkforceResponse -> String)
-> ([DescribeWorkforceResponse] -> ShowS)
-> Show DescribeWorkforceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeWorkforceResponse] -> ShowS
$cshowList :: [DescribeWorkforceResponse] -> ShowS
show :: DescribeWorkforceResponse -> String
$cshow :: DescribeWorkforceResponse -> String
showsPrec :: Int -> DescribeWorkforceResponse -> ShowS
$cshowsPrec :: Int -> DescribeWorkforceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeWorkforceResponse -> Rep DescribeWorkforceResponse x)
-> (forall x.
    Rep DescribeWorkforceResponse x -> DescribeWorkforceResponse)
-> Generic DescribeWorkforceResponse
forall x.
Rep DescribeWorkforceResponse x -> DescribeWorkforceResponse
forall x.
DescribeWorkforceResponse -> Rep DescribeWorkforceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeWorkforceResponse x -> DescribeWorkforceResponse
$cfrom :: forall x.
DescribeWorkforceResponse -> Rep DescribeWorkforceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeWorkforceResponse' 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', 'describeWorkforceResponse_httpStatus' - The response's http status code.
--
-- 'workforce', 'describeWorkforceResponse_workforce' - A single private workforce, which is automatically created when you
-- create your first private work team. You can create one private work
-- force in each Amazon Web Services Region. By default, any
-- workforce-related API operation used in a specific region will apply to
-- the workforce created in that region. To learn how to create a private
-- workforce, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private.html Create a Private Workforce>.
newDescribeWorkforceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workforce'
  Workforce ->
  DescribeWorkforceResponse
newDescribeWorkforceResponse :: Int -> Workforce -> DescribeWorkforceResponse
newDescribeWorkforceResponse Int
pHttpStatus_ Workforce
pWorkforce_ =
  DescribeWorkforceResponse' :: Int -> Workforce -> DescribeWorkforceResponse
DescribeWorkforceResponse'
    { $sel:httpStatus:DescribeWorkforceResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:workforce:DescribeWorkforceResponse' :: Workforce
workforce = Workforce
pWorkforce_
    }

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

-- | A single private workforce, which is automatically created when you
-- create your first private work team. You can create one private work
-- force in each Amazon Web Services Region. By default, any
-- workforce-related API operation used in a specific region will apply to
-- the workforce created in that region. To learn how to create a private
-- workforce, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private.html Create a Private Workforce>.
describeWorkforceResponse_workforce :: Lens.Lens' DescribeWorkforceResponse Workforce
describeWorkforceResponse_workforce :: (Workforce -> f Workforce)
-> DescribeWorkforceResponse -> f DescribeWorkforceResponse
describeWorkforceResponse_workforce = (DescribeWorkforceResponse -> Workforce)
-> (DescribeWorkforceResponse
    -> Workforce -> DescribeWorkforceResponse)
-> Lens
     DescribeWorkforceResponse
     DescribeWorkforceResponse
     Workforce
     Workforce
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeWorkforceResponse' {Workforce
workforce :: Workforce
$sel:workforce:DescribeWorkforceResponse' :: DescribeWorkforceResponse -> Workforce
workforce} -> Workforce
workforce) (\s :: DescribeWorkforceResponse
s@DescribeWorkforceResponse' {} Workforce
a -> DescribeWorkforceResponse
s {$sel:workforce:DescribeWorkforceResponse' :: Workforce
workforce = Workforce
a} :: DescribeWorkforceResponse)

instance Prelude.NFData DescribeWorkforceResponse