{-# 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 #-}
module Amazonka.Lightsail.CreateBucket
(
CreateBucket (..),
newCreateBucket,
createBucket_enableObjectVersioning,
createBucket_tags,
createBucket_bucketName,
createBucket_bundleId,
CreateBucketResponse (..),
newCreateBucketResponse,
createBucketResponse_bucket,
createBucketResponse_operations,
createBucketResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateBucket = CreateBucket'
{
CreateBucket -> Maybe Bool
enableObjectVersioning :: Prelude.Maybe Prelude.Bool,
CreateBucket -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateBucket -> Text
bucketName :: Prelude.Text,
CreateBucket -> Text
bundleId :: Prelude.Text
}
deriving (CreateBucket -> CreateBucket -> Bool
(CreateBucket -> CreateBucket -> Bool)
-> (CreateBucket -> CreateBucket -> Bool) -> Eq CreateBucket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBucket -> CreateBucket -> Bool
$c/= :: CreateBucket -> CreateBucket -> Bool
== :: CreateBucket -> CreateBucket -> Bool
$c== :: CreateBucket -> CreateBucket -> Bool
Prelude.Eq, ReadPrec [CreateBucket]
ReadPrec CreateBucket
Int -> ReadS CreateBucket
ReadS [CreateBucket]
(Int -> ReadS CreateBucket)
-> ReadS [CreateBucket]
-> ReadPrec CreateBucket
-> ReadPrec [CreateBucket]
-> Read CreateBucket
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBucket]
$creadListPrec :: ReadPrec [CreateBucket]
readPrec :: ReadPrec CreateBucket
$creadPrec :: ReadPrec CreateBucket
readList :: ReadS [CreateBucket]
$creadList :: ReadS [CreateBucket]
readsPrec :: Int -> ReadS CreateBucket
$creadsPrec :: Int -> ReadS CreateBucket
Prelude.Read, Int -> CreateBucket -> ShowS
[CreateBucket] -> ShowS
CreateBucket -> String
(Int -> CreateBucket -> ShowS)
-> (CreateBucket -> String)
-> ([CreateBucket] -> ShowS)
-> Show CreateBucket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBucket] -> ShowS
$cshowList :: [CreateBucket] -> ShowS
show :: CreateBucket -> String
$cshow :: CreateBucket -> String
showsPrec :: Int -> CreateBucket -> ShowS
$cshowsPrec :: Int -> CreateBucket -> ShowS
Prelude.Show, (forall x. CreateBucket -> Rep CreateBucket x)
-> (forall x. Rep CreateBucket x -> CreateBucket)
-> Generic CreateBucket
forall x. Rep CreateBucket x -> CreateBucket
forall x. CreateBucket -> Rep CreateBucket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBucket x -> CreateBucket
$cfrom :: forall x. CreateBucket -> Rep CreateBucket x
Prelude.Generic)
newCreateBucket ::
Prelude.Text ->
Prelude.Text ->
CreateBucket
newCreateBucket :: Text -> Text -> CreateBucket
newCreateBucket Text
pBucketName_ Text
pBundleId_ =
CreateBucket' :: Maybe Bool -> Maybe [Tag] -> Text -> Text -> CreateBucket
CreateBucket'
{ $sel:enableObjectVersioning:CreateBucket' :: Maybe Bool
enableObjectVersioning =
Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateBucket' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:bucketName:CreateBucket' :: Text
bucketName = Text
pBucketName_,
$sel:bundleId:CreateBucket' :: Text
bundleId = Text
pBundleId_
}
createBucket_enableObjectVersioning :: Lens.Lens' CreateBucket (Prelude.Maybe Prelude.Bool)
createBucket_enableObjectVersioning :: (Maybe Bool -> f (Maybe Bool)) -> CreateBucket -> f CreateBucket
createBucket_enableObjectVersioning = (CreateBucket -> Maybe Bool)
-> (CreateBucket -> Maybe Bool -> CreateBucket)
-> Lens CreateBucket CreateBucket (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Maybe Bool
enableObjectVersioning :: Maybe Bool
$sel:enableObjectVersioning:CreateBucket' :: CreateBucket -> Maybe Bool
enableObjectVersioning} -> Maybe Bool
enableObjectVersioning) (\s :: CreateBucket
s@CreateBucket' {} Maybe Bool
a -> CreateBucket
s {$sel:enableObjectVersioning:CreateBucket' :: Maybe Bool
enableObjectVersioning = Maybe Bool
a} :: CreateBucket)
createBucket_tags :: Lens.Lens' CreateBucket (Prelude.Maybe [Tag])
createBucket_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateBucket -> f CreateBucket
createBucket_tags = (CreateBucket -> Maybe [Tag])
-> (CreateBucket -> Maybe [Tag] -> CreateBucket)
-> Lens CreateBucket CreateBucket (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateBucket' :: CreateBucket -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateBucket
s@CreateBucket' {} Maybe [Tag]
a -> CreateBucket
s {$sel:tags:CreateBucket' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateBucket) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateBucket -> f CreateBucket)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateBucket
-> f CreateBucket
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createBucket_bucketName :: Lens.Lens' CreateBucket Prelude.Text
createBucket_bucketName :: (Text -> f Text) -> CreateBucket -> f CreateBucket
createBucket_bucketName = (CreateBucket -> Text)
-> (CreateBucket -> Text -> CreateBucket)
-> Lens CreateBucket CreateBucket Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Text
bucketName :: Text
$sel:bucketName:CreateBucket' :: CreateBucket -> Text
bucketName} -> Text
bucketName) (\s :: CreateBucket
s@CreateBucket' {} Text
a -> CreateBucket
s {$sel:bucketName:CreateBucket' :: Text
bucketName = Text
a} :: CreateBucket)
createBucket_bundleId :: Lens.Lens' CreateBucket Prelude.Text
createBucket_bundleId :: (Text -> f Text) -> CreateBucket -> f CreateBucket
createBucket_bundleId = (CreateBucket -> Text)
-> (CreateBucket -> Text -> CreateBucket)
-> Lens CreateBucket CreateBucket Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucket' {Text
bundleId :: Text
$sel:bundleId:CreateBucket' :: CreateBucket -> Text
bundleId} -> Text
bundleId) (\s :: CreateBucket
s@CreateBucket' {} Text
a -> CreateBucket
s {$sel:bundleId:CreateBucket' :: Text
bundleId = Text
a} :: CreateBucket)
instance Core.AWSRequest CreateBucket where
type AWSResponse CreateBucket = CreateBucketResponse
request :: CreateBucket -> Request CreateBucket
request = Service -> CreateBucket -> Request CreateBucket
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateBucket
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBucket)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateBucket))
-> Logger
-> Service
-> Proxy CreateBucket
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateBucket)))
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 Bucket -> Maybe [Operation] -> Int -> CreateBucketResponse
CreateBucketResponse'
(Maybe Bucket -> Maybe [Operation] -> Int -> CreateBucketResponse)
-> Either String (Maybe Bucket)
-> Either String (Maybe [Operation] -> Int -> CreateBucketResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Bucket)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"bucket")
Either String (Maybe [Operation] -> Int -> CreateBucketResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> CreateBucketResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> CreateBucketResponse)
-> Either String Int -> Either String CreateBucketResponse
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 CreateBucket
instance Prelude.NFData CreateBucket
instance Core.ToHeaders CreateBucket where
toHeaders :: CreateBucket -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateBucket -> 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
"Lightsail_20161128.CreateBucket" ::
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 CreateBucket where
toJSON :: CreateBucket -> Value
toJSON CreateBucket' {Maybe Bool
Maybe [Tag]
Text
bundleId :: Text
bucketName :: Text
tags :: Maybe [Tag]
enableObjectVersioning :: Maybe Bool
$sel:bundleId:CreateBucket' :: CreateBucket -> Text
$sel:bucketName:CreateBucket' :: CreateBucket -> Text
$sel:tags:CreateBucket' :: CreateBucket -> Maybe [Tag]
$sel:enableObjectVersioning:CreateBucket' :: CreateBucket -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"enableObjectVersioning" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableObjectVersioning,
(Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bundleId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bundleId)
]
)
instance Core.ToPath CreateBucket where
toPath :: CreateBucket -> ByteString
toPath = ByteString -> CreateBucket -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateBucket where
toQuery :: CreateBucket -> QueryString
toQuery = QueryString -> CreateBucket -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateBucketResponse = CreateBucketResponse'
{
CreateBucketResponse -> Maybe Bucket
bucket :: Prelude.Maybe Bucket,
CreateBucketResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
CreateBucketResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateBucketResponse -> CreateBucketResponse -> Bool
(CreateBucketResponse -> CreateBucketResponse -> Bool)
-> (CreateBucketResponse -> CreateBucketResponse -> Bool)
-> Eq CreateBucketResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateBucketResponse -> CreateBucketResponse -> Bool
$c/= :: CreateBucketResponse -> CreateBucketResponse -> Bool
== :: CreateBucketResponse -> CreateBucketResponse -> Bool
$c== :: CreateBucketResponse -> CreateBucketResponse -> Bool
Prelude.Eq, ReadPrec [CreateBucketResponse]
ReadPrec CreateBucketResponse
Int -> ReadS CreateBucketResponse
ReadS [CreateBucketResponse]
(Int -> ReadS CreateBucketResponse)
-> ReadS [CreateBucketResponse]
-> ReadPrec CreateBucketResponse
-> ReadPrec [CreateBucketResponse]
-> Read CreateBucketResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateBucketResponse]
$creadListPrec :: ReadPrec [CreateBucketResponse]
readPrec :: ReadPrec CreateBucketResponse
$creadPrec :: ReadPrec CreateBucketResponse
readList :: ReadS [CreateBucketResponse]
$creadList :: ReadS [CreateBucketResponse]
readsPrec :: Int -> ReadS CreateBucketResponse
$creadsPrec :: Int -> ReadS CreateBucketResponse
Prelude.Read, Int -> CreateBucketResponse -> ShowS
[CreateBucketResponse] -> ShowS
CreateBucketResponse -> String
(Int -> CreateBucketResponse -> ShowS)
-> (CreateBucketResponse -> String)
-> ([CreateBucketResponse] -> ShowS)
-> Show CreateBucketResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateBucketResponse] -> ShowS
$cshowList :: [CreateBucketResponse] -> ShowS
show :: CreateBucketResponse -> String
$cshow :: CreateBucketResponse -> String
showsPrec :: Int -> CreateBucketResponse -> ShowS
$cshowsPrec :: Int -> CreateBucketResponse -> ShowS
Prelude.Show, (forall x. CreateBucketResponse -> Rep CreateBucketResponse x)
-> (forall x. Rep CreateBucketResponse x -> CreateBucketResponse)
-> Generic CreateBucketResponse
forall x. Rep CreateBucketResponse x -> CreateBucketResponse
forall x. CreateBucketResponse -> Rep CreateBucketResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateBucketResponse x -> CreateBucketResponse
$cfrom :: forall x. CreateBucketResponse -> Rep CreateBucketResponse x
Prelude.Generic)
newCreateBucketResponse ::
Prelude.Int ->
CreateBucketResponse
newCreateBucketResponse :: Int -> CreateBucketResponse
newCreateBucketResponse Int
pHttpStatus_ =
CreateBucketResponse' :: Maybe Bucket -> Maybe [Operation] -> Int -> CreateBucketResponse
CreateBucketResponse'
{ $sel:bucket:CreateBucketResponse' :: Maybe Bucket
bucket = Maybe Bucket
forall a. Maybe a
Prelude.Nothing,
$sel:operations:CreateBucketResponse' :: Maybe [Operation]
operations = Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateBucketResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createBucketResponse_bucket :: Lens.Lens' CreateBucketResponse (Prelude.Maybe Bucket)
createBucketResponse_bucket :: (Maybe Bucket -> f (Maybe Bucket))
-> CreateBucketResponse -> f CreateBucketResponse
createBucketResponse_bucket = (CreateBucketResponse -> Maybe Bucket)
-> (CreateBucketResponse -> Maybe Bucket -> CreateBucketResponse)
-> Lens
CreateBucketResponse
CreateBucketResponse
(Maybe Bucket)
(Maybe Bucket)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucketResponse' {Maybe Bucket
bucket :: Maybe Bucket
$sel:bucket:CreateBucketResponse' :: CreateBucketResponse -> Maybe Bucket
bucket} -> Maybe Bucket
bucket) (\s :: CreateBucketResponse
s@CreateBucketResponse' {} Maybe Bucket
a -> CreateBucketResponse
s {$sel:bucket:CreateBucketResponse' :: Maybe Bucket
bucket = Maybe Bucket
a} :: CreateBucketResponse)
createBucketResponse_operations :: Lens.Lens' CreateBucketResponse (Prelude.Maybe [Operation])
createBucketResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateBucketResponse -> f CreateBucketResponse
createBucketResponse_operations = (CreateBucketResponse -> Maybe [Operation])
-> (CreateBucketResponse
-> Maybe [Operation] -> CreateBucketResponse)
-> Lens
CreateBucketResponse
CreateBucketResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucketResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CreateBucketResponse' :: CreateBucketResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CreateBucketResponse
s@CreateBucketResponse' {} Maybe [Operation]
a -> CreateBucketResponse
s {$sel:operations:CreateBucketResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CreateBucketResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> CreateBucketResponse -> f CreateBucketResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateBucketResponse
-> f CreateBucketResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createBucketResponse_httpStatus :: Lens.Lens' CreateBucketResponse Prelude.Int
createBucketResponse_httpStatus :: (Int -> f Int) -> CreateBucketResponse -> f CreateBucketResponse
createBucketResponse_httpStatus = (CreateBucketResponse -> Int)
-> (CreateBucketResponse -> Int -> CreateBucketResponse)
-> Lens CreateBucketResponse CreateBucketResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateBucketResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateBucketResponse' :: CreateBucketResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateBucketResponse
s@CreateBucketResponse' {} Int
a -> CreateBucketResponse
s {$sel:httpStatus:CreateBucketResponse' :: Int
httpStatus = Int
a} :: CreateBucketResponse)
instance Prelude.NFData CreateBucketResponse