{-# 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.ElasticBeanstalk.CreateStorageLocation
-- 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 bucket in Amazon S3 to store application versions, logs, and
-- other files used by Elastic Beanstalk environments. The Elastic
-- Beanstalk console and EB CLI call this API the first time you create an
-- environment in a region. If the storage location already exists,
-- @CreateStorageLocation@ still returns the bucket name but does not
-- create a new bucket.
module Amazonka.ElasticBeanstalk.CreateStorageLocation
  ( -- * Creating a Request
    CreateStorageLocation (..),
    newCreateStorageLocation,

    -- * Destructuring the Response
    CreateStorageLocationResponse (..),
    newCreateStorageLocationResponse,

    -- * Response Lenses
    createStorageLocationResponse_s3Bucket,
    createStorageLocationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateStorageLocation' smart constructor.
data CreateStorageLocation = CreateStorageLocation'
  {
  }
  deriving (CreateStorageLocation -> CreateStorageLocation -> Bool
(CreateStorageLocation -> CreateStorageLocation -> Bool)
-> (CreateStorageLocation -> CreateStorageLocation -> Bool)
-> Eq CreateStorageLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStorageLocation -> CreateStorageLocation -> Bool
$c/= :: CreateStorageLocation -> CreateStorageLocation -> Bool
== :: CreateStorageLocation -> CreateStorageLocation -> Bool
$c== :: CreateStorageLocation -> CreateStorageLocation -> Bool
Prelude.Eq, ReadPrec [CreateStorageLocation]
ReadPrec CreateStorageLocation
Int -> ReadS CreateStorageLocation
ReadS [CreateStorageLocation]
(Int -> ReadS CreateStorageLocation)
-> ReadS [CreateStorageLocation]
-> ReadPrec CreateStorageLocation
-> ReadPrec [CreateStorageLocation]
-> Read CreateStorageLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateStorageLocation]
$creadListPrec :: ReadPrec [CreateStorageLocation]
readPrec :: ReadPrec CreateStorageLocation
$creadPrec :: ReadPrec CreateStorageLocation
readList :: ReadS [CreateStorageLocation]
$creadList :: ReadS [CreateStorageLocation]
readsPrec :: Int -> ReadS CreateStorageLocation
$creadsPrec :: Int -> ReadS CreateStorageLocation
Prelude.Read, Int -> CreateStorageLocation -> ShowS
[CreateStorageLocation] -> ShowS
CreateStorageLocation -> String
(Int -> CreateStorageLocation -> ShowS)
-> (CreateStorageLocation -> String)
-> ([CreateStorageLocation] -> ShowS)
-> Show CreateStorageLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStorageLocation] -> ShowS
$cshowList :: [CreateStorageLocation] -> ShowS
show :: CreateStorageLocation -> String
$cshow :: CreateStorageLocation -> String
showsPrec :: Int -> CreateStorageLocation -> ShowS
$cshowsPrec :: Int -> CreateStorageLocation -> ShowS
Prelude.Show, (forall x. CreateStorageLocation -> Rep CreateStorageLocation x)
-> (forall x. Rep CreateStorageLocation x -> CreateStorageLocation)
-> Generic CreateStorageLocation
forall x. Rep CreateStorageLocation x -> CreateStorageLocation
forall x. CreateStorageLocation -> Rep CreateStorageLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateStorageLocation x -> CreateStorageLocation
$cfrom :: forall x. CreateStorageLocation -> Rep CreateStorageLocation x
Prelude.Generic)

-- |
-- Create a value of 'CreateStorageLocation' 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.
newCreateStorageLocation ::
  CreateStorageLocation
newCreateStorageLocation :: CreateStorageLocation
newCreateStorageLocation = CreateStorageLocation
CreateStorageLocation'

instance Core.AWSRequest CreateStorageLocation where
  type
    AWSResponse CreateStorageLocation =
      CreateStorageLocationResponse
  request :: CreateStorageLocation -> Request CreateStorageLocation
request = Service -> CreateStorageLocation -> Request CreateStorageLocation
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateStorageLocation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateStorageLocation)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse CreateStorageLocation))
-> Logger
-> Service
-> Proxy CreateStorageLocation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateStorageLocation)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"CreateStorageLocationResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> CreateStorageLocationResponse
CreateStorageLocationResponse'
            (Maybe Text -> Int -> CreateStorageLocationResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateStorageLocationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"S3Bucket")
            Either String (Int -> CreateStorageLocationResponse)
-> Either String Int -> Either String CreateStorageLocationResponse
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 CreateStorageLocation

instance Prelude.NFData CreateStorageLocation

instance Core.ToHeaders CreateStorageLocation where
  toHeaders :: CreateStorageLocation -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateStorageLocation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery CreateStorageLocation where
  toQuery :: CreateStorageLocation -> QueryString
toQuery =
    QueryString -> CreateStorageLocation -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateStorageLocation" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString)
          ]
      )

-- | Results of a CreateStorageLocationResult call.
--
-- /See:/ 'newCreateStorageLocationResponse' smart constructor.
data CreateStorageLocationResponse = CreateStorageLocationResponse'
  { -- | The name of the Amazon S3 bucket created.
    CreateStorageLocationResponse -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateStorageLocationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateStorageLocationResponse
-> CreateStorageLocationResponse -> Bool
(CreateStorageLocationResponse
 -> CreateStorageLocationResponse -> Bool)
-> (CreateStorageLocationResponse
    -> CreateStorageLocationResponse -> Bool)
-> Eq CreateStorageLocationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateStorageLocationResponse
-> CreateStorageLocationResponse -> Bool
$c/= :: CreateStorageLocationResponse
-> CreateStorageLocationResponse -> Bool
== :: CreateStorageLocationResponse
-> CreateStorageLocationResponse -> Bool
$c== :: CreateStorageLocationResponse
-> CreateStorageLocationResponse -> Bool
Prelude.Eq, ReadPrec [CreateStorageLocationResponse]
ReadPrec CreateStorageLocationResponse
Int -> ReadS CreateStorageLocationResponse
ReadS [CreateStorageLocationResponse]
(Int -> ReadS CreateStorageLocationResponse)
-> ReadS [CreateStorageLocationResponse]
-> ReadPrec CreateStorageLocationResponse
-> ReadPrec [CreateStorageLocationResponse]
-> Read CreateStorageLocationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateStorageLocationResponse]
$creadListPrec :: ReadPrec [CreateStorageLocationResponse]
readPrec :: ReadPrec CreateStorageLocationResponse
$creadPrec :: ReadPrec CreateStorageLocationResponse
readList :: ReadS [CreateStorageLocationResponse]
$creadList :: ReadS [CreateStorageLocationResponse]
readsPrec :: Int -> ReadS CreateStorageLocationResponse
$creadsPrec :: Int -> ReadS CreateStorageLocationResponse
Prelude.Read, Int -> CreateStorageLocationResponse -> ShowS
[CreateStorageLocationResponse] -> ShowS
CreateStorageLocationResponse -> String
(Int -> CreateStorageLocationResponse -> ShowS)
-> (CreateStorageLocationResponse -> String)
-> ([CreateStorageLocationResponse] -> ShowS)
-> Show CreateStorageLocationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateStorageLocationResponse] -> ShowS
$cshowList :: [CreateStorageLocationResponse] -> ShowS
show :: CreateStorageLocationResponse -> String
$cshow :: CreateStorageLocationResponse -> String
showsPrec :: Int -> CreateStorageLocationResponse -> ShowS
$cshowsPrec :: Int -> CreateStorageLocationResponse -> ShowS
Prelude.Show, (forall x.
 CreateStorageLocationResponse
 -> Rep CreateStorageLocationResponse x)
-> (forall x.
    Rep CreateStorageLocationResponse x
    -> CreateStorageLocationResponse)
-> Generic CreateStorageLocationResponse
forall x.
Rep CreateStorageLocationResponse x
-> CreateStorageLocationResponse
forall x.
CreateStorageLocationResponse
-> Rep CreateStorageLocationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateStorageLocationResponse x
-> CreateStorageLocationResponse
$cfrom :: forall x.
CreateStorageLocationResponse
-> Rep CreateStorageLocationResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateStorageLocationResponse' 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:
--
-- 's3Bucket', 'createStorageLocationResponse_s3Bucket' - The name of the Amazon S3 bucket created.
--
-- 'httpStatus', 'createStorageLocationResponse_httpStatus' - The response's http status code.
newCreateStorageLocationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateStorageLocationResponse
newCreateStorageLocationResponse :: Int -> CreateStorageLocationResponse
newCreateStorageLocationResponse Int
pHttpStatus_ =
  CreateStorageLocationResponse' :: Maybe Text -> Int -> CreateStorageLocationResponse
CreateStorageLocationResponse'
    { $sel:s3Bucket:CreateStorageLocationResponse' :: Maybe Text
s3Bucket =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateStorageLocationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the Amazon S3 bucket created.
createStorageLocationResponse_s3Bucket :: Lens.Lens' CreateStorageLocationResponse (Prelude.Maybe Prelude.Text)
createStorageLocationResponse_s3Bucket :: (Maybe Text -> f (Maybe Text))
-> CreateStorageLocationResponse -> f CreateStorageLocationResponse
createStorageLocationResponse_s3Bucket = (CreateStorageLocationResponse -> Maybe Text)
-> (CreateStorageLocationResponse
    -> Maybe Text -> CreateStorageLocationResponse)
-> Lens
     CreateStorageLocationResponse
     CreateStorageLocationResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateStorageLocationResponse' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:CreateStorageLocationResponse' :: CreateStorageLocationResponse -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: CreateStorageLocationResponse
s@CreateStorageLocationResponse' {} Maybe Text
a -> CreateStorageLocationResponse
s {$sel:s3Bucket:CreateStorageLocationResponse' :: Maybe Text
s3Bucket = Maybe Text
a} :: CreateStorageLocationResponse)

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

instance Prelude.NFData CreateStorageLocationResponse