{-# 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.Snowball.CreateReturnShippingLabel
-- 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 a shipping label that will be used to return the Snow device to
-- AWS.
module Amazonka.Snowball.CreateReturnShippingLabel
  ( -- * Creating a Request
    CreateReturnShippingLabel (..),
    newCreateReturnShippingLabel,

    -- * Request Lenses
    createReturnShippingLabel_shippingOption,
    createReturnShippingLabel_jobId,

    -- * Destructuring the Response
    CreateReturnShippingLabelResponse (..),
    newCreateReturnShippingLabelResponse,

    -- * Response Lenses
    createReturnShippingLabelResponse_status,
    createReturnShippingLabelResponse_httpStatus,
  )
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.Snowball.Types

-- | /See:/ 'newCreateReturnShippingLabel' smart constructor.
data CreateReturnShippingLabel = CreateReturnShippingLabel'
  { -- | The shipping speed for a particular job. This speed doesn\'t dictate how
    -- soon the device is returned to AWS. This speed represents how quickly it
    -- moves to its destination while in transit. Regional shipping speeds are
    -- as follows:
    CreateReturnShippingLabel -> Maybe ShippingOption
shippingOption :: Prelude.Maybe ShippingOption,
    -- | The ID for a job that you want to create the return shipping label for;
    -- for example, @JID123e4567-e89b-12d3-a456-426655440000@.
    CreateReturnShippingLabel -> Text
jobId :: Prelude.Text
  }
  deriving (CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool
(CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool)
-> (CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool)
-> Eq CreateReturnShippingLabel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool
$c/= :: CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool
== :: CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool
$c== :: CreateReturnShippingLabel -> CreateReturnShippingLabel -> Bool
Prelude.Eq, ReadPrec [CreateReturnShippingLabel]
ReadPrec CreateReturnShippingLabel
Int -> ReadS CreateReturnShippingLabel
ReadS [CreateReturnShippingLabel]
(Int -> ReadS CreateReturnShippingLabel)
-> ReadS [CreateReturnShippingLabel]
-> ReadPrec CreateReturnShippingLabel
-> ReadPrec [CreateReturnShippingLabel]
-> Read CreateReturnShippingLabel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateReturnShippingLabel]
$creadListPrec :: ReadPrec [CreateReturnShippingLabel]
readPrec :: ReadPrec CreateReturnShippingLabel
$creadPrec :: ReadPrec CreateReturnShippingLabel
readList :: ReadS [CreateReturnShippingLabel]
$creadList :: ReadS [CreateReturnShippingLabel]
readsPrec :: Int -> ReadS CreateReturnShippingLabel
$creadsPrec :: Int -> ReadS CreateReturnShippingLabel
Prelude.Read, Int -> CreateReturnShippingLabel -> ShowS
[CreateReturnShippingLabel] -> ShowS
CreateReturnShippingLabel -> String
(Int -> CreateReturnShippingLabel -> ShowS)
-> (CreateReturnShippingLabel -> String)
-> ([CreateReturnShippingLabel] -> ShowS)
-> Show CreateReturnShippingLabel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateReturnShippingLabel] -> ShowS
$cshowList :: [CreateReturnShippingLabel] -> ShowS
show :: CreateReturnShippingLabel -> String
$cshow :: CreateReturnShippingLabel -> String
showsPrec :: Int -> CreateReturnShippingLabel -> ShowS
$cshowsPrec :: Int -> CreateReturnShippingLabel -> ShowS
Prelude.Show, (forall x.
 CreateReturnShippingLabel -> Rep CreateReturnShippingLabel x)
-> (forall x.
    Rep CreateReturnShippingLabel x -> CreateReturnShippingLabel)
-> Generic CreateReturnShippingLabel
forall x.
Rep CreateReturnShippingLabel x -> CreateReturnShippingLabel
forall x.
CreateReturnShippingLabel -> Rep CreateReturnShippingLabel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateReturnShippingLabel x -> CreateReturnShippingLabel
$cfrom :: forall x.
CreateReturnShippingLabel -> Rep CreateReturnShippingLabel x
Prelude.Generic)

-- |
-- Create a value of 'CreateReturnShippingLabel' 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:
--
-- 'shippingOption', 'createReturnShippingLabel_shippingOption' - The shipping speed for a particular job. This speed doesn\'t dictate how
-- soon the device is returned to AWS. This speed represents how quickly it
-- moves to its destination while in transit. Regional shipping speeds are
-- as follows:
--
-- 'jobId', 'createReturnShippingLabel_jobId' - The ID for a job that you want to create the return shipping label for;
-- for example, @JID123e4567-e89b-12d3-a456-426655440000@.
newCreateReturnShippingLabel ::
  -- | 'jobId'
  Prelude.Text ->
  CreateReturnShippingLabel
newCreateReturnShippingLabel :: Text -> CreateReturnShippingLabel
newCreateReturnShippingLabel Text
pJobId_ =
  CreateReturnShippingLabel' :: Maybe ShippingOption -> Text -> CreateReturnShippingLabel
CreateReturnShippingLabel'
    { $sel:shippingOption:CreateReturnShippingLabel' :: Maybe ShippingOption
shippingOption =
        Maybe ShippingOption
forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:CreateReturnShippingLabel' :: Text
jobId = Text
pJobId_
    }

-- | The shipping speed for a particular job. This speed doesn\'t dictate how
-- soon the device is returned to AWS. This speed represents how quickly it
-- moves to its destination while in transit. Regional shipping speeds are
-- as follows:
createReturnShippingLabel_shippingOption :: Lens.Lens' CreateReturnShippingLabel (Prelude.Maybe ShippingOption)
createReturnShippingLabel_shippingOption :: (Maybe ShippingOption -> f (Maybe ShippingOption))
-> CreateReturnShippingLabel -> f CreateReturnShippingLabel
createReturnShippingLabel_shippingOption = (CreateReturnShippingLabel -> Maybe ShippingOption)
-> (CreateReturnShippingLabel
    -> Maybe ShippingOption -> CreateReturnShippingLabel)
-> Lens
     CreateReturnShippingLabel
     CreateReturnShippingLabel
     (Maybe ShippingOption)
     (Maybe ShippingOption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReturnShippingLabel' {Maybe ShippingOption
shippingOption :: Maybe ShippingOption
$sel:shippingOption:CreateReturnShippingLabel' :: CreateReturnShippingLabel -> Maybe ShippingOption
shippingOption} -> Maybe ShippingOption
shippingOption) (\s :: CreateReturnShippingLabel
s@CreateReturnShippingLabel' {} Maybe ShippingOption
a -> CreateReturnShippingLabel
s {$sel:shippingOption:CreateReturnShippingLabel' :: Maybe ShippingOption
shippingOption = Maybe ShippingOption
a} :: CreateReturnShippingLabel)

-- | The ID for a job that you want to create the return shipping label for;
-- for example, @JID123e4567-e89b-12d3-a456-426655440000@.
createReturnShippingLabel_jobId :: Lens.Lens' CreateReturnShippingLabel Prelude.Text
createReturnShippingLabel_jobId :: (Text -> f Text)
-> CreateReturnShippingLabel -> f CreateReturnShippingLabel
createReturnShippingLabel_jobId = (CreateReturnShippingLabel -> Text)
-> (CreateReturnShippingLabel -> Text -> CreateReturnShippingLabel)
-> Lens
     CreateReturnShippingLabel CreateReturnShippingLabel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReturnShippingLabel' {Text
jobId :: Text
$sel:jobId:CreateReturnShippingLabel' :: CreateReturnShippingLabel -> Text
jobId} -> Text
jobId) (\s :: CreateReturnShippingLabel
s@CreateReturnShippingLabel' {} Text
a -> CreateReturnShippingLabel
s {$sel:jobId:CreateReturnShippingLabel' :: Text
jobId = Text
a} :: CreateReturnShippingLabel)

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

instance Prelude.NFData CreateReturnShippingLabel

instance Core.ToHeaders CreateReturnShippingLabel where
  toHeaders :: CreateReturnShippingLabel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateReturnShippingLabel -> 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
"AWSIESnowballJobManagementService.CreateReturnShippingLabel" ::
                          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 CreateReturnShippingLabel where
  toJSON :: CreateReturnShippingLabel -> Value
toJSON CreateReturnShippingLabel' {Maybe ShippingOption
Text
jobId :: Text
shippingOption :: Maybe ShippingOption
$sel:jobId:CreateReturnShippingLabel' :: CreateReturnShippingLabel -> Text
$sel:shippingOption:CreateReturnShippingLabel' :: CreateReturnShippingLabel -> Maybe ShippingOption
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ShippingOption" Text -> ShippingOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ShippingOption -> Pair) -> Maybe ShippingOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ShippingOption
shippingOption,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"JobId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jobId)
          ]
      )

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

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

-- | /See:/ 'newCreateReturnShippingLabelResponse' smart constructor.
data CreateReturnShippingLabelResponse = CreateReturnShippingLabelResponse'
  { -- | The status information of the task on a Snow device that is being
    -- returned to AWS.
    CreateReturnShippingLabelResponse -> Maybe ShippingLabelStatus
status :: Prelude.Maybe ShippingLabelStatus,
    -- | The response's http status code.
    CreateReturnShippingLabelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateReturnShippingLabelResponse
-> CreateReturnShippingLabelResponse -> Bool
(CreateReturnShippingLabelResponse
 -> CreateReturnShippingLabelResponse -> Bool)
-> (CreateReturnShippingLabelResponse
    -> CreateReturnShippingLabelResponse -> Bool)
-> Eq CreateReturnShippingLabelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateReturnShippingLabelResponse
-> CreateReturnShippingLabelResponse -> Bool
$c/= :: CreateReturnShippingLabelResponse
-> CreateReturnShippingLabelResponse -> Bool
== :: CreateReturnShippingLabelResponse
-> CreateReturnShippingLabelResponse -> Bool
$c== :: CreateReturnShippingLabelResponse
-> CreateReturnShippingLabelResponse -> Bool
Prelude.Eq, ReadPrec [CreateReturnShippingLabelResponse]
ReadPrec CreateReturnShippingLabelResponse
Int -> ReadS CreateReturnShippingLabelResponse
ReadS [CreateReturnShippingLabelResponse]
(Int -> ReadS CreateReturnShippingLabelResponse)
-> ReadS [CreateReturnShippingLabelResponse]
-> ReadPrec CreateReturnShippingLabelResponse
-> ReadPrec [CreateReturnShippingLabelResponse]
-> Read CreateReturnShippingLabelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateReturnShippingLabelResponse]
$creadListPrec :: ReadPrec [CreateReturnShippingLabelResponse]
readPrec :: ReadPrec CreateReturnShippingLabelResponse
$creadPrec :: ReadPrec CreateReturnShippingLabelResponse
readList :: ReadS [CreateReturnShippingLabelResponse]
$creadList :: ReadS [CreateReturnShippingLabelResponse]
readsPrec :: Int -> ReadS CreateReturnShippingLabelResponse
$creadsPrec :: Int -> ReadS CreateReturnShippingLabelResponse
Prelude.Read, Int -> CreateReturnShippingLabelResponse -> ShowS
[CreateReturnShippingLabelResponse] -> ShowS
CreateReturnShippingLabelResponse -> String
(Int -> CreateReturnShippingLabelResponse -> ShowS)
-> (CreateReturnShippingLabelResponse -> String)
-> ([CreateReturnShippingLabelResponse] -> ShowS)
-> Show CreateReturnShippingLabelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateReturnShippingLabelResponse] -> ShowS
$cshowList :: [CreateReturnShippingLabelResponse] -> ShowS
show :: CreateReturnShippingLabelResponse -> String
$cshow :: CreateReturnShippingLabelResponse -> String
showsPrec :: Int -> CreateReturnShippingLabelResponse -> ShowS
$cshowsPrec :: Int -> CreateReturnShippingLabelResponse -> ShowS
Prelude.Show, (forall x.
 CreateReturnShippingLabelResponse
 -> Rep CreateReturnShippingLabelResponse x)
-> (forall x.
    Rep CreateReturnShippingLabelResponse x
    -> CreateReturnShippingLabelResponse)
-> Generic CreateReturnShippingLabelResponse
forall x.
Rep CreateReturnShippingLabelResponse x
-> CreateReturnShippingLabelResponse
forall x.
CreateReturnShippingLabelResponse
-> Rep CreateReturnShippingLabelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateReturnShippingLabelResponse x
-> CreateReturnShippingLabelResponse
$cfrom :: forall x.
CreateReturnShippingLabelResponse
-> Rep CreateReturnShippingLabelResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateReturnShippingLabelResponse' 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:
--
-- 'status', 'createReturnShippingLabelResponse_status' - The status information of the task on a Snow device that is being
-- returned to AWS.
--
-- 'httpStatus', 'createReturnShippingLabelResponse_httpStatus' - The response's http status code.
newCreateReturnShippingLabelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateReturnShippingLabelResponse
newCreateReturnShippingLabelResponse :: Int -> CreateReturnShippingLabelResponse
newCreateReturnShippingLabelResponse Int
pHttpStatus_ =
  CreateReturnShippingLabelResponse' :: Maybe ShippingLabelStatus
-> Int -> CreateReturnShippingLabelResponse
CreateReturnShippingLabelResponse'
    { $sel:status:CreateReturnShippingLabelResponse' :: Maybe ShippingLabelStatus
status =
        Maybe ShippingLabelStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateReturnShippingLabelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status information of the task on a Snow device that is being
-- returned to AWS.
createReturnShippingLabelResponse_status :: Lens.Lens' CreateReturnShippingLabelResponse (Prelude.Maybe ShippingLabelStatus)
createReturnShippingLabelResponse_status :: (Maybe ShippingLabelStatus -> f (Maybe ShippingLabelStatus))
-> CreateReturnShippingLabelResponse
-> f CreateReturnShippingLabelResponse
createReturnShippingLabelResponse_status = (CreateReturnShippingLabelResponse -> Maybe ShippingLabelStatus)
-> (CreateReturnShippingLabelResponse
    -> Maybe ShippingLabelStatus -> CreateReturnShippingLabelResponse)
-> Lens
     CreateReturnShippingLabelResponse
     CreateReturnShippingLabelResponse
     (Maybe ShippingLabelStatus)
     (Maybe ShippingLabelStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReturnShippingLabelResponse' {Maybe ShippingLabelStatus
status :: Maybe ShippingLabelStatus
$sel:status:CreateReturnShippingLabelResponse' :: CreateReturnShippingLabelResponse -> Maybe ShippingLabelStatus
status} -> Maybe ShippingLabelStatus
status) (\s :: CreateReturnShippingLabelResponse
s@CreateReturnShippingLabelResponse' {} Maybe ShippingLabelStatus
a -> CreateReturnShippingLabelResponse
s {$sel:status:CreateReturnShippingLabelResponse' :: Maybe ShippingLabelStatus
status = Maybe ShippingLabelStatus
a} :: CreateReturnShippingLabelResponse)

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

instance
  Prelude.NFData
    CreateReturnShippingLabelResponse