{-# 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.Mobile.ExportProject
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Exports project configuration to a snapshot which can be downloaded and
-- shared. Note that mobile app push credentials are encrypted in exported
-- projects, so they can only be shared successfully within the same AWS
-- account.
module Amazonka.Mobile.ExportProject
  ( -- * Creating a Request
    ExportProject (..),
    newExportProject,

    -- * Request Lenses
    exportProject_projectId,

    -- * Destructuring the Response
    ExportProjectResponse (..),
    newExportProjectResponse,

    -- * Response Lenses
    exportProjectResponse_downloadUrl,
    exportProjectResponse_shareUrl,
    exportProjectResponse_snapshotId,
    exportProjectResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Mobile.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Request structure used in requests to export project configuration
-- details.
--
-- /See:/ 'newExportProject' smart constructor.
data ExportProject = ExportProject'
  { -- | Unique project identifier.
    ExportProject -> Text
projectId :: Prelude.Text
  }
  deriving (ExportProject -> ExportProject -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportProject -> ExportProject -> Bool
$c/= :: ExportProject -> ExportProject -> Bool
== :: ExportProject -> ExportProject -> Bool
$c== :: ExportProject -> ExportProject -> Bool
Prelude.Eq, ReadPrec [ExportProject]
ReadPrec ExportProject
Int -> ReadS ExportProject
ReadS [ExportProject]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportProject]
$creadListPrec :: ReadPrec [ExportProject]
readPrec :: ReadPrec ExportProject
$creadPrec :: ReadPrec ExportProject
readList :: ReadS [ExportProject]
$creadList :: ReadS [ExportProject]
readsPrec :: Int -> ReadS ExportProject
$creadsPrec :: Int -> ReadS ExportProject
Prelude.Read, Int -> ExportProject -> ShowS
[ExportProject] -> ShowS
ExportProject -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportProject] -> ShowS
$cshowList :: [ExportProject] -> ShowS
show :: ExportProject -> String
$cshow :: ExportProject -> String
showsPrec :: Int -> ExportProject -> ShowS
$cshowsPrec :: Int -> ExportProject -> ShowS
Prelude.Show, forall x. Rep ExportProject x -> ExportProject
forall x. ExportProject -> Rep ExportProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportProject x -> ExportProject
$cfrom :: forall x. ExportProject -> Rep ExportProject x
Prelude.Generic)

-- |
-- Create a value of 'ExportProject' 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:
--
-- 'projectId', 'exportProject_projectId' - Unique project identifier.
newExportProject ::
  -- | 'projectId'
  Prelude.Text ->
  ExportProject
newExportProject :: Text -> ExportProject
newExportProject Text
pProjectId_ =
  ExportProject' {$sel:projectId:ExportProject' :: Text
projectId = Text
pProjectId_}

-- | Unique project identifier.
exportProject_projectId :: Lens.Lens' ExportProject Prelude.Text
exportProject_projectId :: Lens' ExportProject Text
exportProject_projectId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportProject' {Text
projectId :: Text
$sel:projectId:ExportProject' :: ExportProject -> Text
projectId} -> Text
projectId) (\s :: ExportProject
s@ExportProject' {} Text
a -> ExportProject
s {$sel:projectId:ExportProject' :: Text
projectId = Text
a} :: ExportProject)

instance Core.AWSRequest ExportProject where
  type
    AWSResponse ExportProject =
      ExportProjectResponse
  request :: (Service -> Service) -> ExportProject -> Request ExportProject
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ExportProject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ExportProject)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Int -> ExportProjectResponse
ExportProjectResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"downloadUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"shareUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"snapshotId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ExportProject where
  hashWithSalt :: Int -> ExportProject -> Int
hashWithSalt Int
_salt ExportProject' {Text
projectId :: Text
$sel:projectId:ExportProject' :: ExportProject -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectId

instance Prelude.NFData ExportProject where
  rnf :: ExportProject -> ()
rnf ExportProject' {Text
projectId :: Text
$sel:projectId:ExportProject' :: ExportProject -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
projectId

instance Data.ToHeaders ExportProject where
  toHeaders :: ExportProject -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ExportProject where
  toJSON :: ExportProject -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath ExportProject where
  toPath :: ExportProject -> ByteString
toPath ExportProject' {Text
projectId :: Text
$sel:projectId:ExportProject' :: ExportProject -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/exports/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
projectId]

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

-- | Result structure used for requests to export project configuration
-- details.
--
-- /See:/ 'newExportProjectResponse' smart constructor.
data ExportProjectResponse = ExportProjectResponse'
  { -- | URL which can be used to download the exported project configuation
    -- file(s).
    ExportProjectResponse -> Maybe Text
downloadUrl :: Prelude.Maybe Prelude.Text,
    -- | URL which can be shared to allow other AWS users to create their own
    -- project in AWS Mobile Hub with the same configuration as the specified
    -- project. This URL pertains to a snapshot in time of the project
    -- configuration that is created when this API is called. If you want to
    -- share additional changes to your project configuration, then you will
    -- need to create and share a new snapshot by calling this method again.
    ExportProjectResponse -> Maybe Text
shareUrl :: Prelude.Maybe Prelude.Text,
    -- | Unique identifier for the exported snapshot of the project
    -- configuration. This snapshot identifier is included in the share URL.
    ExportProjectResponse -> Maybe Text
snapshotId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ExportProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExportProjectResponse -> ExportProjectResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportProjectResponse -> ExportProjectResponse -> Bool
$c/= :: ExportProjectResponse -> ExportProjectResponse -> Bool
== :: ExportProjectResponse -> ExportProjectResponse -> Bool
$c== :: ExportProjectResponse -> ExportProjectResponse -> Bool
Prelude.Eq, ReadPrec [ExportProjectResponse]
ReadPrec ExportProjectResponse
Int -> ReadS ExportProjectResponse
ReadS [ExportProjectResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportProjectResponse]
$creadListPrec :: ReadPrec [ExportProjectResponse]
readPrec :: ReadPrec ExportProjectResponse
$creadPrec :: ReadPrec ExportProjectResponse
readList :: ReadS [ExportProjectResponse]
$creadList :: ReadS [ExportProjectResponse]
readsPrec :: Int -> ReadS ExportProjectResponse
$creadsPrec :: Int -> ReadS ExportProjectResponse
Prelude.Read, Int -> ExportProjectResponse -> ShowS
[ExportProjectResponse] -> ShowS
ExportProjectResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportProjectResponse] -> ShowS
$cshowList :: [ExportProjectResponse] -> ShowS
show :: ExportProjectResponse -> String
$cshow :: ExportProjectResponse -> String
showsPrec :: Int -> ExportProjectResponse -> ShowS
$cshowsPrec :: Int -> ExportProjectResponse -> ShowS
Prelude.Show, forall x. Rep ExportProjectResponse x -> ExportProjectResponse
forall x. ExportProjectResponse -> Rep ExportProjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportProjectResponse x -> ExportProjectResponse
$cfrom :: forall x. ExportProjectResponse -> Rep ExportProjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'ExportProjectResponse' 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:
--
-- 'downloadUrl', 'exportProjectResponse_downloadUrl' - URL which can be used to download the exported project configuation
-- file(s).
--
-- 'shareUrl', 'exportProjectResponse_shareUrl' - URL which can be shared to allow other AWS users to create their own
-- project in AWS Mobile Hub with the same configuration as the specified
-- project. This URL pertains to a snapshot in time of the project
-- configuration that is created when this API is called. If you want to
-- share additional changes to your project configuration, then you will
-- need to create and share a new snapshot by calling this method again.
--
-- 'snapshotId', 'exportProjectResponse_snapshotId' - Unique identifier for the exported snapshot of the project
-- configuration. This snapshot identifier is included in the share URL.
--
-- 'httpStatus', 'exportProjectResponse_httpStatus' - The response's http status code.
newExportProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExportProjectResponse
newExportProjectResponse :: Int -> ExportProjectResponse
newExportProjectResponse Int
pHttpStatus_ =
  ExportProjectResponse'
    { $sel:downloadUrl:ExportProjectResponse' :: Maybe Text
downloadUrl =
        forall a. Maybe a
Prelude.Nothing,
      $sel:shareUrl:ExportProjectResponse' :: Maybe Text
shareUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotId:ExportProjectResponse' :: Maybe Text
snapshotId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ExportProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | URL which can be used to download the exported project configuation
-- file(s).
exportProjectResponse_downloadUrl :: Lens.Lens' ExportProjectResponse (Prelude.Maybe Prelude.Text)
exportProjectResponse_downloadUrl :: Lens' ExportProjectResponse (Maybe Text)
exportProjectResponse_downloadUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportProjectResponse' {Maybe Text
downloadUrl :: Maybe Text
$sel:downloadUrl:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
downloadUrl} -> Maybe Text
downloadUrl) (\s :: ExportProjectResponse
s@ExportProjectResponse' {} Maybe Text
a -> ExportProjectResponse
s {$sel:downloadUrl:ExportProjectResponse' :: Maybe Text
downloadUrl = Maybe Text
a} :: ExportProjectResponse)

-- | URL which can be shared to allow other AWS users to create their own
-- project in AWS Mobile Hub with the same configuration as the specified
-- project. This URL pertains to a snapshot in time of the project
-- configuration that is created when this API is called. If you want to
-- share additional changes to your project configuration, then you will
-- need to create and share a new snapshot by calling this method again.
exportProjectResponse_shareUrl :: Lens.Lens' ExportProjectResponse (Prelude.Maybe Prelude.Text)
exportProjectResponse_shareUrl :: Lens' ExportProjectResponse (Maybe Text)
exportProjectResponse_shareUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportProjectResponse' {Maybe Text
shareUrl :: Maybe Text
$sel:shareUrl:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
shareUrl} -> Maybe Text
shareUrl) (\s :: ExportProjectResponse
s@ExportProjectResponse' {} Maybe Text
a -> ExportProjectResponse
s {$sel:shareUrl:ExportProjectResponse' :: Maybe Text
shareUrl = Maybe Text
a} :: ExportProjectResponse)

-- | Unique identifier for the exported snapshot of the project
-- configuration. This snapshot identifier is included in the share URL.
exportProjectResponse_snapshotId :: Lens.Lens' ExportProjectResponse (Prelude.Maybe Prelude.Text)
exportProjectResponse_snapshotId :: Lens' ExportProjectResponse (Maybe Text)
exportProjectResponse_snapshotId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportProjectResponse' {Maybe Text
snapshotId :: Maybe Text
$sel:snapshotId:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
snapshotId} -> Maybe Text
snapshotId) (\s :: ExportProjectResponse
s@ExportProjectResponse' {} Maybe Text
a -> ExportProjectResponse
s {$sel:snapshotId:ExportProjectResponse' :: Maybe Text
snapshotId = Maybe Text
a} :: ExportProjectResponse)

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

instance Prelude.NFData ExportProjectResponse where
  rnf :: ExportProjectResponse -> ()
rnf ExportProjectResponse' {Int
Maybe Text
httpStatus :: Int
snapshotId :: Maybe Text
shareUrl :: Maybe Text
downloadUrl :: Maybe Text
$sel:httpStatus:ExportProjectResponse' :: ExportProjectResponse -> Int
$sel:snapshotId:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
$sel:shareUrl:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
$sel:downloadUrl:ExportProjectResponse' :: ExportProjectResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
downloadUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
shareUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snapshotId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus